Expand-Archive

Extracts files from a specified archive (zipped) file.
Expand-Archive [-Path*] <String> [-DestinationPath*] <String> [-Force] [-Confirm] [-WhatIf] [<CommonParameters>]
Expand-Archive [-DestinationPath*] <String> [-Force] -LiteralPath* <String> [-Confirm] [-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
-DestinationPath <String>

  • This value is required

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>]

Forces the command to run without asking for user confirmation.

-LiteralPath <String>

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
  • Accepts pipeline input ByValue

Specifies the path to the archive file.

-Confirm [<SwitchParameter>]

  • Default value is false

Prompts you for confirmation before running the cmdlet.Prompts you for confirmation before running the cmdlet.

-WhatIf [<SwitchParameter>]

  • Default value is false

Shows what would happen if the cmdlet runs. The cmdlet is not run.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:ArchivesDraft.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.

Related Links

Compress-Archive