Q. How can I create a compressed file with PowerShell 5?
A. PowerShell 5 introduces a new Archive module which enables the creation and extraction of ZIP files. An easy way to add files to an archive is to list the files then pipe those objects to an archive, for example:
Get-ChildItem *.jpg | Compress-Archive -DestinationPath pic.zip -CompressionLevel Optimal
Files can be added to an existing archive using the same format command and adding -Update, for example:
Get-ChildItem *.png | Compress-Archive -DestinationPath pic.zip -CompressionLevel Optimal -Update
To extract use:
Expand-Archive pic.zip -DestinationPath D:\Temp
Each week, John Savill answers all of your toughest tech questions about the worlds of Windows Server, Azure, and beyond. Read his past IT advice here, and email your questions to john@savilltech.com.