Just realized when writing this that i haven’t talked about how to check if a remote computer has a specific Software Update or Hotfix which i have to do a blog post on that later on and last but not least there’s really good reports in SCCM for checking that also. When running the script you want to see the following ReturnValue 0 which means that the Invoke-Wmimethod was started successfully and after that take a look at the Uninstall log.
We do one Invoke-WmiMethod for no restart and one for Force Restart of remote computer depending on what you have specified in the ForceRestart parameter, Yes or No We also put a log file in C:\temp\2887595Uninstall.txt this file it self just contains a bunch of gibberish but it’s a way of seeing that Wusa.exe was launched and makes it easier to troubleshoot if anything seems to be not working properly. If you wanted to try out the command for your self, just open a command prompt and exclude Variables for KB and LOG (since those variables are for the Powershell script to interpret) like this and input the KB id number.
The rest of the script just runs a Invoke-wmimethod which starts an CMD process with the help of the Win32_Process WMI class and in the ArgumentList parameter we list a CMD command we want to run that in it’s self uninstalls the update with the help of a application called Wusa.exe that’s a part of Windows and lives in the %Windir%\System32 folder.Ĭmd /c wusa.exe /quiet /uninstall /KB:$($KBid) /norestart /log:C:\temp\$($KBid)Uninstall.txt Don’t include the KB in the parameter! $ForceRestart = Yes or No and if nothing is specified it will count as No $Computername = Computer name (remote computer you want to run the command on) $KBid = Software update KB (Knowledge Base) id for example 2887424. Invoke-WmiMethod -computername $Computername -class Win32_Process -Name Create -ArgumentList 'cmd /c wusa.exe /quiet /uninstall /KB:$($KBid) /norestart /log:C:\temp\$($KBid)Uninstall.txt'
Invoke-WmiMethod -computername $Computername -class Win32_Process -Name Create -ArgumentList 'cmd /c wusa.exe /quiet /uninstall /KB:$($KBid) /Forcerestart /log:C:\temp\$($KBid)Uninstall.txt' This is a proof of concept and are intended for both people with limited knowledge in powershell or for those who can modify it for their own needs.
Instead of having to go in to the Control panel – Program and Features – Installed Updates and from there right-click and choose Uninstall we wan’t to automate this task so we could go and have coffee instead or just focus our attention on something more productive.
I did a blog post a few weeks back on how to Force an install of software update in SCCM through WMI with help of Powershell įor this post i want to focus on how to Uninstall a software update remotely which is fairly simple and does’t involve SCCM at all because, Well SCCM doesn’t have any method for doing that. Regardless if you are using your own WSUS to deploy Windows updates or you have it integrated and using a SUP role in SCCM or you are just getting them directly from Microsoft the process of uninstalling them are still the same.