Like a lot of folks in IT there have been a lot of times where I have to uninstall something from a machine and don’t want to involve the user. Sometimes the reason that the software has to come off is that the user shouldn’t have put it there in the first place too. PSExec has always been an option for an action like this but Powershell is a candidate now too.
Before going through what it takes to accomplish, here is the standard Disclaimer.
For this one, rather than going fully automated we are going to gather some info and then use it. Changing this for full automation is simple but at the moment we will treat it as a “one off”. Due to the fact that we are taking this approach we are going to assume we don’t know the full software name either. You can add this info right in the command but I am a fan of variables for this. By doing it this way I can save the script and use it repeatedly easier.
We know the machine we are looking for and the software, next we have to check for that software and get some info. Specifically we query WMI to verify if that software is even on the machine. If the software is there then the “IdentifyingNumber” property is what we need.
Armed with this information the only remaining step is to query WMI again for the uninstall.
Of course if you like you could again use a variable for the ID but I find it easier to paste in directly. As long as you have appropriate access to the end machine this should be all that’s needed.
A great way to utilize a script like this is by building it into a small GUI application. If you would like to go that route you can find an article about creating a GUI for a Powershell here.