Trending October 2023 # A Complete Guide To Powershell Unzip # Suggested November 2023 # Top 18 Popular |

Trending October 2023 # A Complete Guide To Powershell Unzip # Suggested November 2023 # Top 18 Popular

You are reading the article A Complete Guide To Powershell Unzip updated in October 2023 on the website We hope that the information we have shared is helpful to you. If you find the content interesting and meaningful, please share it with your friends and continue to follow and support us for the latest updates. Suggested November 2023 A Complete Guide To Powershell Unzip

Introduction to PowerShell unzip

PowerShell unzip extracts the files and folders from the specific Zip file on the same path that the ZIP file exists or the specific destination path using the Expand-Archive command or by using System.IO.Compression namespace to decompress files and folders.

Start Your Free Data Science Course

Hadoop, Data Science, Statistics & others

Syntax of PowerShell unzip

Given below are the syntax mentioned:

1. Expand-Archive cmdlet syntax.

[-Force] [-PassThru] [-WhatIf] [-Confirm] [-Force] [-PassThru] [-WhatIf] [-Confirm]

2. Unzip using NameSpace.

[System.IO.Compression.ZipFile]::ExtractToDirectory(String, String)

[System.IO.Compression.ZipFile]::ExtractToDirectory(String, String, Boolean)

[System.IO.Compression.ZipFile]::ExtractToDirectory(String, String, Encoding)

[System.IO.Compression.ZipFile]::ExtractToDirectory(String, String, Encoding, Boolean)

How do unzip Commands work in PowerShell?

Expand-Archive is the inbuilt command that is used to extract the contents from the ZIP files. Other archive file formats like RAR, 7ZIP aren’t supported by this cmdlet.

ZIP utility commands (Compress-Archive and Expand-Archive) are part of the PowerShell module called Microsoft.PowerShell.Archive.


Get-Command Expand-Archive


For the source path, PowerShell uses any of the Path or the LiteralPath (If you don’t want to use the wildcard). You can use the source and destination path as the local path or the NAS folder path with the appreciate read and write permissions.

In case you don’t have this module installed in your system, you can download it from the PowerShell gallery.

Second, you can use the .Net namespace [System.IO.Compression], class ZipFile with ExtractToDirectory methods where you can provide the source path of the Zip file and the destination path to extract the same. This method requires chúng tôi should present on the system.

Third, in case your files are RAR, ISO, or 7Zip apart from the ZIP file, you can download the 7ZIP module for PowerShell supported by the 7ZIP utility. There is a command Expand-7Zip which extracts the compressed mostly all kinds of the compressed file.

Examples of PowerShell unzip

Given below are the examples of PowerShell unzip:

Example #1

Expand-Archive command to extract files and folders on Local computer.

The below command will extract the chúng tôi on the source path and the Destination path E:Extract.


Expand-Archive -Path -DestinationPath E:Extract -Verbose

Please note that in the above command, destination folder Extract, might not exist but the Expand-Archive command creates it automatically if it is not there already.


Example #2

Expand-Archive command with -Force parameter.

If the files already exist on the destination path then with -Force parameter then it overwrites the files and folders on the destination path.

Without -Force parameter.

With -Force Parameter.

Expand-Archive -Path -DestinationPath E:Extract -Force -Verbose


Example #3

Expand-Archive command to extract data on a local path.

To extract the data on the local path, use the dot (.) for the destination path as shown below.


Expand-Archive -DestinationPath . -Force -Verbose

The above command will extract the E:DSC.Zip to the C:temp folder path.

Example #4

Expand-Archive command for a shared drive.

We can also use the shared path as the source and the destination with the appropriate read and write permissions.


-DestinationPath \adsharedtempextracted -Force -Verbose

The above command extracts the ZIP on the shared folder path.

Example #5

System.IO.Compression.ZipFile namespace.

This method uses the .Net namespace System.IO.Compression class ZIPFile to extract the data from the compressed file.

In case if this ZipFile class isn’t available, we can add the assembly as shown below.


Add-Type -AssemblyName System.IO.Compression.ZipFile

To extract the data.


The above command will extract ZIP file content to the C:TempExtracted path. If the destination folder (“Extracted”) doesn’t exist, it will create that folder.

When you use the same destination to extract files again, it will throw an exception with destination files that already exist.

To overwrite destination files, we need to add a third parameter and which is a Boolean value. Use $true to overwrite.



To know more about encoding class check the below link:

Below is the example of europa encoding:


To overwrite the destination files with encoding, use the $true boolean argument.


[System.IO.Compression.ZipFile]::ExtractToDirectory( "", "C:TempExtracted", $encode,$true)

Example #6

Using 7Zip module commands.

In case your files are compressed with other software than ZIP, you can use 7ZIP to extract the compressed file (even ZIP files). 7ZIP is very popular software but you don’t need to install the software, only you need to download and install modules.

You first need to download and Install the 7Zip module 7Zip4PowerShell.

To download and install the module, use the below command.


Install-Module 7Zip4PowerShell -Scope CurrentUser -Force -Verbose

Alternatively, you can also download the module from the PowerShell gallery and follow the instructions given.

Below commands are shipped with this module.


Get-Command -Module 7Zip4PowerShell


To extract the compressed file, we will use the Expand-7Zip command.


Expand-7Zip -ArchiveFileName C:TempDSC.rar -TargetPath C:Extracted -Verbose


If the destination folder doesn’t exist, it will create automatically.


Files and folders are compressed and stored into a single file called the ZIP file. PowerShell has various ways to extract them without downloading and installing any single software. The above-mentioned methods work both on cross-platform applications.

Recommended Articles

This is a guide to PowerShell unzip. Here we discuss the introduction, how do unzip commands work in PowerShell? and examples respectively. You may also have a look at the following articles to learn more –

You're reading A Complete Guide To Powershell Unzip

Update the detailed information about A Complete Guide To Powershell Unzip on the website. We hope the article's content will meet your needs, and we will regularly update the information to provide you with the fastest and most accurate information. Have a great day!