0
我有一個zip文件的目錄結構,它 ,我想用一個腳本來提取他們 我的劇本至今調用表達下探雙引號
$7zexe = "c:\bin\7za.exe"
$arg = ""
Get-ChildItem -Recurse -Include *.zip |
ForEach-Object { $argout = $_.Directory.Name
$arg = " e `"$_`" -o`"$argout`""
$cmdline = $7zexe, $arg -join ""
$cmdline
Invoke-Expression -command "$cmdline "
}
,但我得到以下錯誤
c:\bin\7za.exe e "E:\tmp\the folder\the sub folder\my_big_file.zip" -o"the sub folder"
Invoke-Expression : The string starting:
At line:1 char:86
+ c:\bin\7za.exe e "E:\tmp\the folder\the sub folder\my_big_file.zip" -o"the sub folder <<<< "
is missing the terminator: ".
At x:\mydocs\testscript.ps1:9 char:18
+ Invoke-Expression <<<< -command "$cmdline "
+ CategoryInfo : ParserError: (:String) [Invoke-Expression], IncompleteParseException
+ FullyQualifiedErrorId : TerminatorExpectedAtEndOfString,Microsoft.PowerShell.Commands.InvokeExpressionCommand
不知怎的,它看起來像PowerShell是下降我收「
我與& OPER試了一下ator和我也嘗試用數組替換參數
[Array]$arg = "e ", "`"$_`""," -o`"$argout`""
任何暗示讚賞!
感謝 它看起來像解決方案,但我仍然有一些問題,清理環境(不知PowerShell的確信和arg是一個數組???!? 加入 '[字符串] $ ARG =「」' 解決這個問題來了 – nobs