How to add a progress bar to your PowerShell script

[Update] If you want to learn how to calculate seconds remaining when using progress bars, head on over to this post!

A very typical workflow when working with PowerShell, is to iterate through a collection of data. Inside each loop, you would perform some action, like getting or setting some data for instance. Depending on the size of the array, and the particular work you are doing within each iteration, this might often be a part of your script where users get little-to-none feedback that the script is still running.

Usability-wise this is bad, and you should strive to give the user some feedback that ‘stuff is happening‘. In this post I will show you how you can use the Write-Progress cmdlet to add a progress bar to your script, to give the user the needed visibility to know it’s running. (more…)