Trying to get a variable into Start-Process msiexec, however, when I run the script, it returns:
Start-Process : A positional parameter cannot be found that accepts argument
'{BCF4CF24-88AB-45E1-A6E6-40C8278A70C5}'.
Powershell script:
$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 }