How to zip and unzip files using PowerShell on Windows 10

You can use PowerShell to compress and extract files from zip containers, and in this guide, you'll learn the steps on how to do it.

PowerShell zip and unzip commands
PowerShell zip and unzip commands

On Windows 10 (or 11), you can use a zip file for packaging and compressing files and folders for easier sharing or storing files that you don’t use frequently.

Although you can use File Explorer to quickly create a zip file or extract the contents of a zipped file, you can also use PowerShell to perform the same tasks more efficiently. In addition, you can even select the compression ratio to zip files even faster or optimize to save space.

This guide will teach you how to zip and unzip files and folders using PowerShell commands on Windows 10. Although these instructions are focused on Windows 10, they also apply to systems running Windows 11.

Zip files from PowerShell

To zip files with PowerShell on Windows 10, use these steps:

  1. Open Start on Windows 10.

  2. Search for PowerShell, right-click the top result and click the Run as administrator option.

  3. Type the following PowerShell command to compress and zip a folder with files and press Enter:

    Compress-Archive -Path C:\SOURCE\PATH\TO\YOUR\FILES\* -CompressionLevel Optimal -DestinationPath C:\DESTINATION\PATH\ZIPPEDFILE.zip

    Zip files using PowerShell

    In the command, change the source and destination with your specific paths. The wildcard “*” tells the command to compress the source folder’s contents.

Once you complete the steps, PowerShell will compress the folder and all its content, creating a new .zip file with a compressed version of the files.

Add more files to zip from PowerShell

To update the zip file with more files from PowerShell, use these steps:

  1. Open Start.

  2. Search for PowerShell, right-click the top result and click the Run as administrator option.

  3. Type the following command to update the zip file with additional files and press Enter:

    Compress-Archive -Path C:\SOURCE\PATH\TO\YOUR\FILES -Update -DestinationPath C:\DESTINATION\PATH\ZIPPEDFILE.zip

    Update zip file using PowerShell

    In the command, change the source and destination with your specific paths.

After completing the steps, the zip folder will be updated with the new files you specified in the command.

Change zip compression ratio from PowerShell

To change the compression ratio of a zip file using PowerShell, use these steps:

  1. Open Start.

  2. Search for PowerShell, right-click the top result and click the Run as administrator option.

  3. Type the following PowerShell command to compress files with different ratios and press Enter:

    Compress-Archive -Path C:\SOURCE\PATH\TO\YOUR\FILES\* -CompressionLevel Fastest -DestinationPath C:\DESTINATION\PATH\ZIPPEDFILE.zip

    Compression ratio for zip file using PowerShell

    In the command, change the source and destination with your specific paths.

If you want to specify the zip compression ratio, make sure to set the “CompressionLevel” flag with the ratio you want:

  • Fastest: It uses less time to compress files, which may result in a larger zip file.
  • NoCompression: Uses no compression resulting in a zip file that is the same size as the total amount of the uncompressed files.
  • Optimal: It uses more time but compresses the files with the highest ratio.

Once you complete the steps, the zip folder will be created using the specified compression ratio.

Unzip files from PowerShell

To unzip files with PowerShell commands on Windows 10, use these steps:

  1. Open Start.

  2. Search for PowerShell, right-click the top result and click the Run as administrator option.

  3. Type the following command to unzip a folder with files and press Enter:

    Expand-Archive -Path C:\SOURCE\PATH\TO\YOUR\ZIPFILE\ZIPPED.zip -DestinationPath C:\DESTINATION\PATH\UNZIP

    Extract files from zip using PowerShell

    In the command, change the source and destination with your specific paths.

After completing the steps, PowerShell will extract all the files and folders from the specified zip container.

About the author

Mauro Huculak is a Windows How-To Expert who started Pureinfotech in 2010 as an independent online publication. He has also been a Windows Central contributor for nearly a decade. Mauro has over 14 years of experience writing comprehensive guides and creating professional videos about Windows and software, including Android and Linux. Before becoming a technology writer, he was an IT administrator for seven years. In total, Mauro has over 20 years of combined experience in technology. Throughout his career, he achieved different professional certifications from Microsoft (MSCA), Cisco (CCNP), VMware (VCP), and CompTIA (A+ and Network+), and he has been recognized as a Microsoft MVP for many years. You can follow him on X (Twitter), YouTube, LinkedIn and About.me.