How to zip and unzip files using PowerShell on Windows 10, 11

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 / Image: Mauro Huculak
  • To zip (compress) files, open PowerShell (admin) and run the Compress-Archive -Path C:\SOURCE\FILES\* -CompressionLevel Optimal -DestinationPath C:\DESTINATION\ZIPPEDFILE.zip command.
  • To unzip (extract) files, open PowerShell (admin) and run the Expand-Archive -Path C:\SOURCE\ZIPPED.zip -DestinationPath C:\DESTINATION\UNZIP command.
  • You can also use PowerShell to add more files to the archival format or change the compression ratio.

On Windows 10 (or 11), you can use a zip file to package and compress files and folders for easier sharing or to store 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 with commands. In addition, you can even select the compression ratio to zip files even faster or optimize to save space.

In this guide, I 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 (or 11), use these steps:

  1. Open Start on Windows.

  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 to match 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 to match 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 to match 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: This method uses no compression, resulting in a zip file that is the same size as the total number of 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 (or 11), 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 to match your specific paths.

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

Update June 13, 2024: This guide has been updated to ensure accuracy and reflect changes to the process.

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