Hi,
today i was trying to uninstall the the software using PowerShell.
i See few blog posts about uninstalling software using PowerShell they re recommending WMI to uninstall software using the .Uninstalled() method. But i think this method is not right because it don’t un-installed the software properly. Sometime uninstalling software using these method cause system/laptop to crash.
In my view, un-installation should be done by proper way.
Lets un-install winzip in a proper way. You can also script it.
we are going to use WMI but in another way.
Lets Start
lets see installed software first using the below command.
Get-WmiObject -Class win32_product
it is showing the list of all installed software.
Now see if we have winzip installed. we are piped the previous command to Where-Object and searching for name which contain winzip in it.
Get-WmiObject -Class win32_product | where { $_.Name -like "*Winzip*"}
Yes we have WinZip installed
Lets pipe the above command to Format-List to that we can see all the members of the Winzip.
Get-WmiObject -Class win32_product | where { $_.Name -like "*Winzip*"} | format-List *
This will give us all the member properties of Winzip. The property in which we are interested is “LocalPackage”
and you can see that install LocalPackage contains a path to a .msi executable file. and we can uninstall .msi files uisng MSIEXEC. lets check the which command line switches MSIEXEC support.
Simple run MSIEXEC and it will show you all the switches msiexec support. The switch which we are going to use is /x and /passive
lets combine the all commands together. I put the first command in to $Wzip variable.
- $Wzip = Get-WmiObject -Class win32_product | where { $_.Name -like "*Winzip*"}
- $Wzip.localPackage
Now try to run $Wzip.localPackage and this will show us the WinZip install source
msiexec /x $wzip.localpackage /passive