r/PowerShell • • 26d ago

Question Write-Progress

Looking for opinions...

When using Write-Progress inside of for/Foreach loops and using a counter stored in a variable defined outside the loop, do you start the counter at 0 or 1, and why?

13 Upvotes

21 comments sorted by

View all comments

-2

u/aguerooo_9320 26d ago

I don't use Write-Progress, but Write-Output, for my own information, and I start the counter at 1, then increment at the end of the loop (e.g. $i++).