PowerShell Script to Split, Replace and Rename File Names in the Folder Recursively and in Bulk

Important Note: The File renaming in bulk can result in dangerous results in not handled correctly.  This post is ONLY to share my learning’s to serve you as a guidance to build your own scripts for similar requirements.  Requirement: I had a folder which contained sub-folders and then files.  The naming convention of file names is “<string> –  <string> – <string>.mp4”.  Out of which the first String is too lengthy and common for all files which I wanted to get rid of it.  Script: function Rename-Files ($folder) {     $files = dir $folder | where {! $_.PsIsContainer}     # $files […]

Read more

PowerShell Script to Remotely Update Registry keys and Restart Services on multiple Computers with Progress bar showing the Status of the Script

Requirement: In an enterprise automation its very often a requirement to REMOTELY Query list of servers/computers/desktops Apply a registry change to the servers/computers/desktops Restart a Service on the servers/computers/desktops Solution: Implementing a PowerShell script for such an automation requirement helps you easily build enterprise capabilities to the script like: Showing a Progress bar indicating current activity of the script and how much percentage the processing is completed Implement safety check to avoid attempts connect to an inaccessible or offline servers/computers/desktops Display output to standard output channel Examples: PowerShell in PowerGUI: Code: $Servers = Get-Content “C:\Temp\Servers.txt” $TotalServersCount = ($Servers).Count $PerCentageCounter = […]

Read more