Skip navigation
Create compressed files with PowerShell 5

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 john@savilltech.com.

Hide comments

Comments

  • Allowed HTML tags: <em> <strong> <blockquote> <br> <p>

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.
Publish