Expand-​Archive

Extracts files from a specified archive (zipped) file.

Syntax

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

Description

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.

Examples

Example 1: Extract the contents of an archive

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.

Example 2: Extract the contents of an archive in the current folder

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.

Required Parameters

-LiteralPath

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.

Type:String
Aliases:PSPath
Position:Named
Default value:None
Accept pipeline input:True (ByPropertyName)
Accept wildcard characters:False
-Path

Specifies the path to the archive file.

Type:String
Position:0
Default value:None
Accept pipeline input:True (ByPropertyName, ByValue)
Accept wildcard characters:False

Optional Parameters

-Confirm

Prompts you for confirmation before running the cmdlet.

Type:SwitchParameter
Aliases:cf
Position:Named
Default value:False
Accept pipeline input:False
Accept wildcard characters:False
-DestinationPath

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.

Type:String
Position:1
Default value:None
Accept pipeline input:False
Accept wildcard characters:False
-Force

Forces the command to run without asking for user confirmation.

Type:SwitchParameter
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False
-WhatIf

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

Type:SwitchParameter
Aliases:wi
Position:Named
Default value:False
Accept pipeline input:False
Accept wildcard characters:False

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