PowerShell scripts to download a file and expand zip file

It all began because I have a folder of Sysinternals tools and I thought now would be a good time to update it with the latest version. 

But downloading a zip file and expanding to the folder is so old-fashioned surely? ;-) Why not use PowerShell to make it a one-click process. 

Thus was born Download-File.ps1 which downloads a given link to a file and optionally passes it through down the pipeline. It’s a simple script, just a wrapper around the Invoke-WebRequest cmdlet. Then was born Expand-Zip.ps1 which takes a zip file – either as a file, or a stream of bytes down the pipeline (from Download-File.ps1 for instance) –  and expands this into a folder (over-writing the contents by default, but can optionally not over-write). 

Neither of these are a big deal but it’s been so long since I did some PowerShell coding that I felt I must mention them. Maybe it’s of use to someone else too!

Now I can do something like the following (put it in a script of its own of course) and it will download the latest version of Sysinternals and expand to the specified folder. 

 I added some progress bars too to show what’s happening. Both scripts can be found in my GitHub repo: Download-File.ps1 and Expand-Zip.ps1