Start-Process:找不到接受参数的位置参数

时间:2017-10-20 20:16:53

标签: powershell

尝试将变量放入Start-Process msiexec,但是,当我运行脚本时,它会返回:

Start-Process:找不到接受参数

的位置参数

' {BCF4CF24-88AB-45E1-A6E6-40C8278A70C5}&#39 ;.

Powershell脚本:

$properties = "identifyingnumber","name"
$filter = "Name LIKE '%Some software%'"

$getWMI = Get-WmiObject -Class win32_product  -Filter $filter | Select-Object -Property $properties | Sort-Object Name
if ($getWMI -and $getWMI.Length -eq 2) {
        $id0 = $getWMI[0].identifyingnumber
        $id1 = $getWMI[1].identifyingnumber
        (Start-Process msiexec.exe -ArgumentList '"/X' $id1 '/QN KLPASSWD=randompass'"" -Wait).ExitCode  
}
else { exit }

0 个答案:

没有答案