How to Zip and Unzip Files using PowerShell on Windows 11 or 10?

PowerShell is a powerful tool that can automate various Windows 11/10 tasks, including zipping and unzipping files. In this gearupwindows guide, we’ll walk you through the steps to compress and extract files using PowerShell on Windows 11 and 10.

How to Zip and Unzip Files using PowerShell on Windows 11 or 10?

Zipping Files Using PowerShell

To zip files using PowerShell, follow these steps:-

Step 1. Open the Windows PowerShell app on your computer.

Step 2. Then, navigate to the folder containing the files you want to zip by typing “cd” followed by the folder path, for example:-

cd C:\Test

Step 3. To create a zip file, use the Compress-Archive cmdlet and specify the files you want to include in the archive. For example, to create a zip file called “myarchive.zip” containing all the files in the current folder, use the following command:-

Compress-Archive -Path * -DestinationPath myarchive.zip

Once the command is executed, PowerShell will create a zip file with the specified name and include all the specified files.

Unzipping Files Using PowerShell

To extract files from a zip archive using PowerShell, follow these steps:-

Step 1. Open PowerShell by typing “PowerShell” into the Start menu and selecting the “Windows PowerShell” app.

Step 2. Navigate to the folder where the zip archive is located by typing “cd” followed by the folder path, for instance:-

cd C:\Test

Step 3. To extract all files from the zip archive, use the Expand-Archive cmdlet and specify the zip file path and the destination folder path. For example, to extract all files from a zip file called “myarchive.zip” to a folder called “ExtractedFiles,” use the following command:-

Expand-Archive -Path myarchive.zip -DestinationPath ExtractedFiles

Once the command is executed, PowerShell will extract all files from the specified zip archive to the specified destination folder.

That’s it! With these simple steps, you can easily compress and extract files using PowerShell on Windows 11 and 10.

Leave a Reply