PARAM (
[string] $SourceZipPath, #= "X:\Somepath\Full\Of\Zipfiles",
[string] $DestinationPath #= "X:\Somepath\to\extract\to"
)
$ErrorActionPreference = "Stop"
$Shell = New-Object -com Shell.Application
$ZipFiles = Get-Childitem $SourceZipPath -Recurse | % {& "C:\Program Files\7-Zip\7z.exe" "x" $_.fullname "-o" $DestinationPath} -Include *.ZIP
請當我試圖運行它提供了以下錯誤提示在上面的代碼修正:解壓縮.zip文件
ForEach-Object : Cannot bind parameter 'RemainingScripts'. Cannot convert the "-Include" value of type "System.String" to type "System.Management.Automation.ScriptBlock".
At C:\Users\******\Desktop\Zip****Extractor-v0.6.ps1:11 char:53
-Recurse | % {& "C:\Program Files\7-Zip\7z.exe" "x" "-o" $Destinatio ...
+ CategoryInfo:InvalidArgument:(:)[ForEach-Object], ParentContainsErrorRecordException
+FullyQualifiedErrorId : CannotConvertArgumentNoMessage,Microsoft.PowerShell.Commands.ForEachObjectCommand
'-Include * .ZIP'應該是管之前,即'GET-Childitem $ SourceZipPath -Recurse -Include * .ZIP |' – 4c74356b41