PowerShell Progress Bar with Time Remaining

I spent a bunch of time searching the internet for some pre-baked PowerShell code showing how to display a progress bar that showed more than percent complete or records to completion. I couldn’t find anything, so spend some time writing one.

This snippet should be pretty usable for anyone familiar with PowerShell loops.

It gives you a nice little display like this, displaying total number of records, percentage complete, time left, as well as records complete.

PercentAndTimeRemainingProgress

 

2015-09-16: Updated to set % Complete to Always 2 decimal places.

5 Comments:

  1. Thanks, exactly what i was looking for!
    Note: it’s one too many } at the end.

  2. Nesting a fraction within a fraction is like nails down a chalkboard. An alternative equation is:

    ($SecondsElapsed * ($items.count – $i))/$i

    Note: $i != 0

  3. This is great! A very concise snippet of code. Wish I found this days ago.

    Can you add in a ‘-Status “Processing”‘ parameter to the Write-Progress line in your example? It took me a while to figure out that PowerShell silently uses “Processing” if the -Status parameter is not defined.

Leave a Reply

Your email address will not be published. Required fields are marked *