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…)

Get-FileType

The other day I came across an excellent function written by Boe Prox, called Get-FileSignature. His function will read a file and give you the Hex and ASCII signature of the file. I thought a bit about how I could use this function and came across several sites on-line listing the file signatures of known file formats. That got me thinking! What if I could create a function that tried to determine a files type based on its file signature?  (more…)