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