Display Progress bar in PowerShell scripts

By Ramu Soft

This explains how to get a progress bar in powershell while processing items.

If you have a file copy/search operation implemented in powershell, generally it stays at a particular place with blank screen while script is doing the search/copy operation. In such cases, we can provide a progress bar to end user which gives him a status of copy/search operation.

In the below example, I am displaying 1000 numbers with 1 second delay between each number and configured a status bar for the user to know how much printing is completed.

for ($i=1; $i -le 1000; $i++)
{
Write
-Host $i
start-sleep -Milliseconds 10
write-progress -activity "Printing Numbers" -status "Progress:" -percentcomplete (($i/1000)*100)
}


Display Progress bar in PowerShell scripts  (2017 Views)