Expand Archive - PowerShell


The Expand-Archive command in PowerShell extracts the contents of a compressed archive file into a specified destination folder. It is primarily used to unpack files from compressed formats such as ZIP, RAR, 7z, tar, and TAR.GZ.


Expand-Archive -Path <ArchivePath> -DestinationPath <DestinationPath> [<CommonParameters>]


| Option | Description | Default |
| -CompressionLevel | Specifies the compression level when creating self-extracting archives. | Normal |
| -DestinationPath | The path to the destination folder where extracted files will be placed. | Current directory |
| -Force | Overwrites existing files in the destination folder without prompting. | $false |
| -IncludeBaseDirectory | Retains the top-level folder structure within the archive during extraction. | $false |
| -Path | The path to the compressed archive file. | Required |
| -Sfx | Creates a self-extracting executable archive that can be executed to extract files without a supported utility. | $false |


Extract a ZIP archive:

Expand-Archive -Path "C:\Path\To\Archive.zip" -DestinationPath "C:\Path\To\Extract"

Extract a RAR archive with overwriting:

Expand-Archive -Path "C:\Path\To\Archive.rar" -DestinationPath "C:\Path\To\Extract" -Force

Extract a tar archive including base directories:

Expand-Archive -Path "C:\Path\To\Archive.tar" -DestinationPath "C:\Path\To\Extract" -IncludeBaseDirectory

Common Issues

  • Extraction failure: Ensure the archive file is not corrupted and that the specified destination folder has sufficient permissions.
  • Incomplete extraction: Verify that the archive file is not password-protected. If it is, specify the password using the -Password parameter.
  • Overwriting files without confirmation: Use the -Force option with caution, as it will permanently overwrite existing files.


  • Use Compress-Archive to create compressed archives that can be later extracted using Expand-Archive.
  • Combine Expand-Archive with Import-Archive to add files to an existing archive.
  • Use Get-Archive to inspect the contents of an archive before extraction.
  • Compress-Archive
  • Get-Archive
  • Import-Archive