Ossie Akaunu
asked on
Powershell Uninstall using WMIC
I have a requitrment to uninstall a suite of applications using WMIC. Initially I wanted to use the below script
$ObjApp = Get-WmiObject win32_product -filter "IdentifyingNumber = '$FindAppbyGUID'" -namespace root/cimv2
If ($ObjApp.Uninstall().Retur nValue -eq 0)
{
Write-Host "Uninstall SUCCESSFULL"
}
Else
{
Write-Host "Uninstall FAILED"
}
For whatever reason this application will not uninstall with the above code neither via msiexec /X /qn etc etc.
However the application will uninstall with below WMIC command ...
wmic product where identifyingnumber="{AAAA00 A0-BB11-22 CC-D333-4E 4444E44444 }" call uninstall
My method of running this in powershell is ...
$Cmd = "wmic product where identifyingnumber="{AAAA00 A0-BB11-22 CC-D333-4E 4444E44444 }" call uninstall"
Invoke-Expression $Cmd
I also tried ...
$Cmd = 'wmic product where identifyingnumber="{AAAA00 A0-BB11-22 CC-D333-4E 4444E44444 }" call uninstall'
Invoke-Expression $Cmd
Any Help will be appreciated.
Thank You in Advance
$ObjApp = Get-WmiObject win32_product -filter "IdentifyingNumber = '$FindAppbyGUID'" -namespace root/cimv2
If ($ObjApp.Uninstall().Retur
{
Write-Host "Uninstall SUCCESSFULL"
}
Else
{
Write-Host "Uninstall FAILED"
}
For whatever reason this application will not uninstall with the above code neither via msiexec /X /qn etc etc.
However the application will uninstall with below WMIC command ...
wmic product where identifyingnumber="{AAAA00
My method of running this in powershell is ...
$Cmd = "wmic product where identifyingnumber="{AAAA00
Invoke-Expression $Cmd
I also tried ...
$Cmd = 'wmic product where identifyingnumber="{AAAA00
Invoke-Expression $Cmd
Any Help will be appreciated.
Thank You in Advance
The last one looks correct - what's the result?
ASKER
The error message I get is ...
wmic : Unexpected switch at this level.
At line:1 char:1
+ wmic product where identifyingnumber="{63B5DA 5A-477B-43 8D-A6A0-11 8787 ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~ ~~~~~~~~~~ ~~~~~~~~~~ ~~~~~~~~~~ ~~~
+ CategoryInfo : NotSpecified: (Unexpected switch at this level.:String) [], RemoteException
+ FullyQualifiedErrorId : NativeCommandError
wmic : Unexpected switch at this level.
At line:1 char:1
+ wmic product where identifyingnumber="{63B5DA
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (Unexpected switch at this level.:String) [], RemoteException
+ FullyQualifiedErrorId : NativeCommandError
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.