I will need to remove a software from more than 30 Windows 2003 servers once I confirmed it has the memory leaking bug. To make the job easier, I prefer to use script (as always):
$app = Get-WmiObject -Class Win32_Product -ComputerName (Get-Content servers.txt) | Where-Object {$_.Name -match “Software Name”}
$app.Uninstall()
NOTE:
1) Win32_Product WMI class is not enabled on Windows 2003 by default, so you have to install ‘WMI windows Installer Provider’ under ‘Management and Monitoring Tools’ through the Add/Remove Windows components in control panel.
2) If you are not sure the software name, use the this script to do a query first: Get-WmiObject -Class win32_product -ComputerName remote_server_IP
The ‘WMI windows Installer Provider’ can be installed by script too.
First, copy the following 3 files from the i386 folder to a shared folder
MSI.MF_
MSI.MO_
MSIPROV.DL_
Second, create a text file named WbemMSI.txt in the same share folder, and type in the following entries.
[Unattended]
InstallFilesPath=”\\server\share\file”
[Components]
WbemMSI = On
Third, run the script to install this Windows component ‘ sysocmgr /i:%windir%\inf\sysoc.inf /u:\\server\share\file\WbemMSI.txt ‘
nice one, thanks. It seems that on my windows 7 is no method uninstall!?
I used this:
$app = Get-WmiObject -Class Win32_Product | Where-Object {$_.Name -match “Java”}
$app.Uninstall()
Method invocation failed because [System.Object[]] doesn’t contain a method named ‘Uninstall’. At line:1 char:15 FullyQualifiedErrorId: MethodNotFound
I run PS as administrator!
Any ideas?
Problem solved – I am an idiot! Looking for Java is a little lacky – result is more than one!
hi there, in my case i have change it just a litle and comes to this:
$app = Get-WmiObject -Class Win32_Product | Where-Object {$_.Name -like “Java”}
msiexec /x $app.IdentifyingNumber /qn
and i getting to work , the $app.uninstall() do not work for me eather. Hope this will work for you to.
When i try above command getting some error
ou cannot call a method on a null-valued expression.
At line:2 char:1
+ $app.Uninstall()
+ ~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [], RuntimeException
+ FullyQualifiedErrorId : InvokeMethodOnNull
Any idea how to give a no-restart option after an uninstallation via this script?