*Warning. This article was written using the September 2014 PowerShell v5 Preview*
(OK, I was really looking for an excuse to use the below picture in a blog post)
One of the most popular and long standing requests for PowerShell is native support for working with Zip files. With PowerShell v5 we get two new cmdlets Compress-Archive and and Expand-Archive. Here’s a couple of examples of how they work.
1) Create a Zip file
C:\Test contains a number of text files. We want to zip them up into one convenient file.
Compress-Archive -Path C:\Test\* -DestinationPath C:\Zip\Test.zip -CompressionLevel Optimal
and now we have the zip file:
Note: as of this release there are three Compression Levels, the default of which is Optimal.
2) Update a Zip file
Now we add an extra file to C:\Test and want to update the zip file with this new file
Compress-Archive -Path C:\Test\* -DestinationPath C:\Zip\Test.zip -Update
Here’s the new file, now contained in the zip file:
3) Expand a Zip file
Now we want to expand a zip file. Let’s use the one we just created and expand it to a different folder C:\Expand.
Expand-Archive -Path C:\Zip\Test.zip -DestinationPath C:\Expand
Here are the files:
All pretty straightforward, but it’s great to have this simple functionality finally native 🙂