Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Ever wondered how far a long running Powershell script has come?
I use this piece of code in pretty much all my scripts to keep track, very useful if you process large amounts of data:
1: $i = 1
2:
3: foreach ($item in $collection) {
4:
5: $pct = (($i / $collection.count)*100)
6: Write-Progress -activity "Processing..." -status "Progress: $([int]$pct)%" -PercentComplete $pct
7:
8: # processing stuff goes here
9:
10: $i++
11: }
Feel free to use it wherever you want… :)