Add Some Zip to Your PowerShell
We’ve been looking at the System.IO
namespace. Existing cmdlets and PowerShell providers cover much of this namespace's functionality. But that doesn’t mean there aren’t situations where using the .NET class directly isn’t useful. One area is System.IO.Compression
, specifically, the classes related to ZIP files. PowerShell has cmdlets, Compress-Archive
and Expand-Archive
that are easy to use and most likely will meet 99% of your needs in PowerShell. Make time to look at help and examples for those commands if you’ve never used them before.
That leaves a little room for us to play, so let’s see what kind of fun we can have. I’m going to be using PowerShell 7. You might see slightly different results in Windows PowerShell.
.NET Discovery
The first step is to discover what we don’t know. We’ll begin with a .NET trick to show what assemblies are currently loaded into our session. I already know what to filter on to save a little time.