这个Powershell脚本调用远程服务器上的MsiZap,根据它的产品代码删除软件(如果存在)。
我收到解析错误,说明以下内容:
At C:\Scripts\Remove Tools\Remove-Tools.ps1:41 char:83
+ ... {57753043-0E65-4B13-9AF0-AC09CFC29C03} }
+ ~
You must provide a value expression following the '-' operator.
At C:\Scripts\Remove Tools\Remove-Tools.ps1:41 char:83
+ ... {57753043-0E65-4B13-9AF0-AC09CFC29C03} }
+ ~~~~~~~~~~~~~~~~~~~~~~
Unexpected token '4B13-9AF0-AC09CFC29C03' in expression or statement.
+ CategoryInfo : ParserError: (:) [], ParseException
+ FullyQualifiedErrorId : ExpectedValueExpression
这里是所有切换代码:
foreach ($product in $products){
Switch -wildcard($product.IdentifyingNumber){
"*C18D2775-33F4-4CE9-B071-4ECC78DA5E31*" { "Removing Software" >> "$spath\log.log"
./psexec \\$computer -s -w c:\ cmd /c msizap.exe TW {C18D2775-33F4-4CE9-B071-4ECC78DA5E31} }
"*59AB19CE-2706-4F7B-B567-403BB584D92E*" { "Removing Software" >> "$spath\log.log"
./psexec \\$computer -s -w c:\ cmd /c msizap.exe TW {59AB19CE-2706-4F7B-B567-403BB584D92E} }
"*57753043-0E65-4B13-9AF0-AC09CFC29C03*" { "Removing Software" >> "$spath\log.log"
./psexec \\$computer -s -w c:\ cmd /c msizap.exe TW {57753043-0E65-4B13-9AF0-AC09CFC29C03} }
"*4B932CA6-727B-4948-91E3-FFCF75CE3478*" { "Removing Software" >> "$spath\log.log"
./psexec \\$computer -s -w c:\ cmd /c msizap.exe TW {4B932CA6-727B-4948-91E3-FFCF75CE3478} }
}
}
以下行是导致错误的行:
"*57753043-0E65-4B13-9AF0-AC09CFC29C03*" { "Removing Software" >> "$spath\log.log"
./psexec \\$computer -s -w c:\ cmd /c msizap.exe TW {57753043-0E65-4B13-9AF0-AC09CFC29C03} }
其他相同的行(除了产品代码中的更改)不会出现此错误。