This snippet of PowerShell was written to have show users something more interesting than “Sleeping for 15 seconds” in a script. Notice that I splat the progress parameters.
#The math works only with seconds $pauseSecs = 1 $MaxWaitSecs =15 for ($i=0; $i -lt $MaxWaitSecs; $i+=$pauseSecs) { [int]$pct = ($i/$MaxWaitSecs)*100 $Params = @{ Activity = "Please wait" PercentComplet = $pct CurrentOperation = "$i seconds elapsed, $pct% of maximum $MaxWaitSecs seconds wait time" Status = "Pausing" } Write-Progress @params Start-Sleep -seconds $pauseSecs }