'PowerShell msiexec silent uninstall
I'm attempting to uninstall a program "Global VPN Client" from over 150 computers, these computers have multiple versions with different identifying numbers. I'm try to perform this silently and with no reboot. So far here's my code:
$GUID = Get-WmiObject -Class Win32_Product | where name -Like "Global VPN Client" | select IdentifyingNumber
$Arguments = "/x" + $GUID + "/qn REBOOT=ReallySuppress"
Start-Process msiexec.exe -Wait -ArgumentList $Arguments
The process starts however it doesn't perform this silently, my assumption is because the last line starts the "/x" and $GUID, this starting the uninstall before passing the last bit of the arguments.
Any advice or insight to get this working and have the wanted behavior?
Solution 1:[1]
First problem:
$GUID = Get-WmiObject -Class Win32_Product | where name -Like "Global VPN Client" | select IdentifyingNumber
The Select-Object (alias select) command outputs an object, so the GUID value actually is in $GUID.IdentifyingNumber. You could use it as such, but it would be conceptually clearer to assign the value of property IdentifyingNumber to $GUID:
$GUID = Get-WmiObject -Class Win32_Product | where name -Like "Global VPN Client" | select -Expand IdentifyingNumber
# alternative:
$GUID = (Get-WmiObject -Class Win32_Product | where name -Like "Global VPN Client").IdentifyingNumber
There is another problem:
$Arguments = "/x" + $GUID + "/qn REBOOT=ReallySuppress"
A space character is missing between /x and the $GUID. Either explicitly insert a space or let PowerShell do it automatically by passing an array of arguments:
$Arguments = "/x", $GUID, "/qn", "REBOOT=ReallySuppress"
Start-Process msiexec.exe -Wait -ArgumentList $Arguments
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | zett42 |
