我有一个.zip
文件,需要使用Powershell解压它的全部内容。我正在这样做,但它似乎不起作用:
$shell = New-Object -ComObject shell.application
$zip = $shell.NameSpace("C:\a.zip")
MkDir("C:\a")
foreach ($item in $zip.items()) {
$shell.Namespace("C:\a").CopyHere($item)
}
怎么了?目录C:\a
仍然为空。
发布于 2015-01-05 06:31:34
在PowerShell v5+中,内置了一个Expand-Archive command (以及压缩归档):
Expand-Archive c:\a.zip -DestinationPath c:\a
发布于 2017-10-11 12:25:25
在PowerShell v5.1中,这与v5略有不同。根据MS文档,它必须有一个-Path
参数来指定存档文件路径。
Expand-Archive -Path Draft.Zip -DestinationPath C:\Reference
或者,这可以是一个实际的路径:
Expand-Archive -Path c:\Download\Draft.Zip -DestinationPath C:\Reference
发布于 2019-05-24 16:23:01
将Expand-Archive
cmdlet与以下参数集之一一起使用:
Expand-Archive -LiteralPath C:\source\file.Zip -DestinationPath C:\destination
Expand-Archive -Path file.Zip -DestinationPath C:\destination
https://stackoverflow.com/questions/27768303
复制相似问题