POSHTIP #32 – Zip And Unzip Your Archives Using PowerShell v5

POSHTIP #32 – Zip and Unzip your archives using PowerShell v5

This PowerShell Tip is an update of the following PoSHTip: POSHTIP #1 Unzip your archive. Thanks to the WMF 5.0, zip and unzip archive is pretty simple!

WMF 5 includes two new cmdlets:

  • Compress-Archive
  • Expand-Archive

Ok, you want to zip an archive? Type the following command:

PS > Compress-Archive C:\folder\ folder.zip

It’s done! You can add the following parameter: “-CompressionLevel”

  • Fastest: Use the fastest compression method available to decrease processing time; this can result in larger file sizes.
  • NoCompression: Do not compress the source files.
  • Optimal: Processing time is dependent on file size.

To unzip your archive, use the “Expand-Archive” cmdlet:

PS > Expand-Archive -Path ".\folder.zip" -DestinationPath "C:\Tmp"

 

 

Thanks for reading! You can follow me on Twitter @PrigentNico

About Nicolas 282 Articles
I work as an IT Production Manager, based in Paris (France) with a primary focus on Microsoft technologies. I have 10 years experience in administering Windows Servers. . I am a Microsoft MVP for Cloud & Datacenter Management. I also received the PowerShell Hero 2016 award by PowerShell.0rg. And finally, I am "MCSE: Cloud Platform and Infrastructure", "MCSA: Windows Servers", "Administering & Deploying SCCM", and CheckPoint CCSA certified.