Create compressed files with PowerShell 5

Manage archive files with PowerShell 5.

John Savill

March 18, 2016

1 Min Read
Create compressed files with PowerShell 5

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 [email protected].

  •  

About the Author

Sign up for the ITPro Today newsletter
Stay on top of the IT universe with commentary, news analysis, how-to's, and tips delivered to your inbox daily.

You May Also Like