How to Create Progress Bars in PowerShell — MCP Magazine Online

When automating a ton of tasks, creating a visual cue on the activate is helpful in knowing that things are running smoothly.

No one likes to wait. We all want stuff done now but, unfortunately, that’s not always possible. Things take time, and we’re forced to put up with waiting an indefinite amount of time for task X to complete. Writing PowerShell code and waiting for execution is no different. We sometimes expect automation to be instantaneous when, in reality, PowerShell must interact with various other systems that have their own schedules. When the script will take awhile, and the script author is aware of this ahead of time, skilled script writers will add important indicators in the script to keep the user aware that something is happening instead of staring at a blinking cursor for minutes at a time.

Script writers have a couple of options to build visual cues to the user as to what’s going on in the background. They may choose to use various Write-Verbose or Write-Information references indicating the status. Or they can use PowerShell’s built-in progress bar support to not only display messages but also to show a graphical representation of the percentage of work that’s been done.

Read more at MCPMag

Leave a Reply