Skip to content
PowerShell Commands

Expand-Archive

Expand-Archive [[-DestinationPath] <String>] [-Confirm] [-Force] -LiteralPath* <String> [-WhatIf][<CommonParameters>]
Expand-Archive [-Path*] <String> [[-DestinationPath] <String>] [-Confirm] [-Force] [-WhatIf] [<CommonParameters>]

The Expand-Archive cmdlet extracts files from a specified zipped archive file to a specified destination folder. An archive file allows multiple files to be packaged, and optionally compressed, into a single zipped file for easier distribution and storage.

Parameters

-Confirm [<SwitchParameter>]

  • Default value is False
  • Accepts pipeline input False

Prompts you for confirmation before running the cmdlet.

-DestinationPath <String>

  • Default value is None
  • Accepts pipeline input False

Specifies the path to the folder in which you want the command to save extracted files. Enter the path to a folder, but do not specify a file name or file name extension. This parameter is required.

-Force [<SwitchParameter>]

  • Default value is False
  • Accepts pipeline input False

Forces the command to run without asking for user confirmation.

-LiteralPath <String>

  • This value is required
  • Default value is None
  • Accepts pipeline input ByPropertyName

Specifies the path to an archive file. Unlike the Path parameter, the value of LiteralPath is used exactly as it is typed. Wildcard characters are not supported. If the path includes escape characters, enclose each escape character in single quotation marks, to instruct Windows PowerShell not to interpret any characters as escape sequences.

-Path <String>

  • This value is required
  • Default value is None
  • Accepts pipeline input ByPropertyName

Specifies the path to the archive file.

-WhatIf [<SwitchParameter>]

  • Default value is False
  • Accepts pipeline input False

Shows what would happen if the cmdlet runs. The cmdlet is not run.

<CommonParameters>

This cmdlet supports the common parameters: Verbose, Debug,ErrorAction, ErrorVariable, WarningAction, WarningVariable,OutBuffer, PipelineVariable, and OutVariable.

Inputs
System.String
You can pipe a string that contains a path to an existing archive file.
Outputs
System.IO.FileInfo or System.IO.DirectoryInfo
Examples
  1. Extract the contents of an archive:
    PS C:\> Expand-Archive -LiteralPath C:\Archives\Draft.Zip -DestinationPath C:\Reference
    

    This command extracts the contents of an existing archive file, Draft.zip, into the folder specified by the DestinationPath parameter, C:\Reference.

  2. Extract the contents of an archive in the current folder:
    PS C:\> Expand-Archive -Path Draft.Zip -DestinationPath C:\Reference
    

    This command extracts the contents of an existing archive file in the current folder, Draft.zip, into the folder specified by the DestinationPath parameter, C:\Reference.

Additional Notes

This work is licensed under a Creative Commons Attribution 4.0 International. It is attributed to Microsoft Corporation and can be found here.

PowerShell Commands