Expand-Archive
Extracts files from a specified archive (zipped) file.
Syntax
Expand-Archive
[-Path] <String>
[[-DestinationPath] <String>]
[-Force]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
Expand-Archive
-LiteralPath <String>
[[-DestinationPath] <String>]
[-Force]
[-WhatIf]
[-Confirm]
[<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.
Parameters
-Confirm
Prompts you for confirmation before running the cmdlet.
Type: | SwitchParameter |
Aliases: | cf |
Position: | Named |
Default value: | False |
Required: | 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.
Type: | String |
Position: | 1 |
Default value: | Current location |
Required: | False |
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 |
Required: | False |
Accept pipeline input: | False |
Accept wildcard characters: | False |
-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 PowerShell not to interpret any characters as escape sequences.
Type: | String |
Aliases: | PSPath |
Position: | Named |
Default value: | None |
Required: | True |
Accept pipeline input: | True |
Accept wildcard characters: | False |
-Path
Specifies the path to the archive file.
Type: | String |
Position: | 0 |
Default value: | None |
Required: | True |
Accept pipeline input: | True |
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 |
Required: | False |
Accept pipeline input: | False |
Accept wildcard characters: | False |
Inputs
You can pipe a string that contains a path to an existing archive file.
Outputs
None