Saturday, May 11, 2019

Powershell: Display progress indicater

Implementing progress bar sometimes would be efficient as we can identify if the task is still ongoing or unexpectedly hunged.

Let's try 'Write-Progress' cmdlet.


for ($i = 1; $i -le 50; $i++ )
{
    Write-Progress -Activity "Title of progress bar" -Status "$i% Complete:" -PercentComplete $i;

# Do something, such as file copy or time consuming tasks etc..
    Sleep 2;

}


No comments:

Post a Comment