我很难通过Powershell获取要提取的.7z
文件。
我的PowerShell函数如下所示:
function unzip($file, $destination)
{
& 'C:\Program Files\7-Zip\7z.exe' x -y $file -o"$destination";
}
我知道这个错误:
7z.exe :
At restoreQA.ps1:26 char:5
+ & 'C:\Program Files\7-Zip\7z.exe' x -y $file -o"$destination";
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:String) [], RemoteException
+ FullyQualifiedErrorId : NativeCommandError
Command Line Error:
Too short switch:
-o
似乎存在某种解析错误,但我尝试了各种不同的组合,以使其正常工作。
对为什么这不起作用有什么想法吗?
发布于 2016-03-18 13:26:22
您需要将-o放在引号中:
& 'C:\Program Files\7-Zip\7z.exe' x -y $file "-o$destination"
https://stackoverflow.com/questions/36085518
复制相似问题