Expand-Archive
Extracts files from a specified archive (zipped) file.
语法
Path (默认值)
Expand-Archive
[-Path] <String>
[[-DestinationPath] <String>]
[-Force]
[-PassThru]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
LiteralPath
Expand-Archive
[[-DestinationPath] <String>]
-LiteralPath <String>
[-Force]
[-PassThru]
[-WhatIf]
[-Confirm]
[<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.
示例
Example 1: Extract the contents of an archive
This example extracts the contents of an existing archive file into the folder specified by the DestinationPath parameter.
Expand-Archive -LiteralPath 'C:\Archives\Draft[v1].zip' -DestinationPath C:\Reference
In this example, the LiteralPath parameter is used because the filename contains characters that could be interpreted as wildcards.
Example 2: Extract the contents of an archive in the current folder
This example extracts the contents of an existing archive file in the current folder into the folder specified by the DestinationPath parameter.
Expand-Archive -Path Draftv2.zip -DestinationPath C:\Reference
参数
-Confirm
Prompts you for confirmation before running the cmdlet.
参数属性
类型: | SwitchParameter |
默认值: | False |
支持通配符: | False |
不显示: | False |
别名: | cf |
参数集
(All)
Position: | Named |
必需: | False |
来自管道的值: | False |
来自管道的值(按属性名称): | False |
来自剩余参数的值: | False |
-DestinationPath
By default, Expand-Archive
creates a folder in the current ___location that's the same name as the
ZIP file. The parameter allows you to specify the path to a different folder. The target folder is
created if it doesn't exist.
参数属性
类型: | String |
默认值: | A folder in the current ___location |
支持通配符: | False |
不显示: | False |
参数集
(All)
Position: | 1 |
必需: | False |
来自管道的值: | False |
来自管道的值(按属性名称): | False |
来自剩余参数的值: | False |
-Force
Use this parameter to overwrite existing files. By default, Expand-Archive
doesn't overwrite.
参数属性
类型: | SwitchParameter |
默认值: | None |
支持通配符: | False |
不显示: | False |
参数集
(All)
Position: | Named |
必需: | False |
来自管道的值: | False |
来自管道的值(按属性名称): | False |
来自剩余参数的值: | False |
-LiteralPath
Specifies the path to an archive file. Unlike the Path parameter, the value of LiteralPath is used exactly as it's typed. Wildcard characters aren't 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.
参数属性
类型: | String |
默认值: | None |
支持通配符: | False |
不显示: | False |
别名: | PSPath |
参数集
LiteralPath
Position: | Named |
必需: | True |
来自管道的值: | False |
来自管道的值(按属性名称): | True |
来自剩余参数的值: | False |
-PassThru
Causes the cmdlet to output a list of the files expanded from the archive.
参数属性
类型: | SwitchParameter |
默认值: | None |
支持通配符: | False |
不显示: | False |
参数集
(All)
Position: | Named |
必需: | False |
来自管道的值: | False |
来自管道的值(按属性名称): | False |
来自剩余参数的值: | False |
-Path
Specifies the path to the archive file.
参数属性
类型: | String |
默认值: | None |
支持通配符: | False |
不显示: | False |
参数集
Path
Position: | 0 |
必需: | True |
来自管道的值: | True |
来自管道的值(按属性名称): | True |
来自剩余参数的值: | False |
-WhatIf
Shows what would happen if the cmdlet runs. The cmdlet isn't run.
参数属性
类型: | SwitchParameter |
默认值: | False |
支持通配符: | False |
不显示: | False |
别名: | wi |
参数集
(All)
Position: | Named |
必需: | False |
来自管道的值: | False |
来自管道的值(按属性名称): | False |
来自剩余参数的值: | False |
CommonParameters
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutBuffer, -OutVariable, -PipelineVariable, -ProgressAction, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.
输入
String
You can pipe a string that contains a path to an existing archive file.
输出
None
By default, this cmdlet returns no output.
FileSystemInfo
When you use the PassThru parameter, this cmdlet returns a list of files that were expanded from the archive.
备注
The Compress-Archive
cmdlet uses UTF-8 encoding. Other ZIP archive tools may use a different
encoding scheme. When extracting files with filenames not stored using UTF-8 encoding,
Expand-Archive
uses the raw value found in the archive. This can result in a filename that's
different than the source filename stored in the archive.