I’d like to uninstall a program from a remote computer. I know the location of the MSI that was used for the install, it’s on the remote server and the path can be seen in the variable $MSIPathFile below.
When I run the following script:
$TargetServer = "d-vasbiz01"
$MSIPathFile = "c:\biztalkdeployment\x.Int.MIS-3.0.0.msi"
Invoke-Command -Computer $TargetServer -ScriptBlock {Param($MSIPathFile, $UninstallFlag, $QuietFlag) Start-Process msiexec.exe "/x" $MSIPathFile "/qn"} -ArgumentList "$MSIPathFile", "/x", "/qn"
I get the following error:
Invoke-Command -Computer $TargetServer -ScriptBlock {Param($MSIPathFile, $UninstallFlag, $QuietFlag) Start-Process msiexec.exe "/x" $MSIPathFile "/qn"} -ArgumentList "$MSIPathFile", "/x", "/qn"
A positional parameter cannot be found that accepts argument 'c:\biztalkdeployment\x.Int.MIS-3.0.0.msi'.
+ CategoryInfo : InvalidArgument: (:) [Start-Process], ParameterBindingException
+ FullyQualifiedErrorId : PositionalParameterNotFound,Microsoft.PowerShell.Commands.StartProcessCommand
Can anyone please advise what I’m doing wrong?
This is not really an answer to my question but it solves my problem of remotely uninstalling an MSI. I hope this can help someone else as I’ve spent the last 3 hours trying various techniques!
It turns out this can be achieved with a single line of code!
(Get-WmiObject -Class Win32_Product -Filter “Name=’x.Int.MIS for BizTalk 2010 3.0.0′” -ComputerName $TargetServer ).Uninstall()
Courtesy of the following technet page: http://technet.microsoft.com/en-us/library/dd347651.aspx