Adding multiple Windows hotfixes with wusa and PowerShell

Today I have been exploring a bit in patching  hyper-v hosts with windows updates and hotfixes and when we have a cluster we can use the CAU ( Cluster Aware Updating) that can help you in the process of getting those hotfixes on in a automated fashion but that does not work on single hosts..

In my blog post about checking the hosts for updates and hotfixes I also have added the functionality to download the hotfixes from Microsoft´s servers..

An easy way to add several hotfixes to a host is to use PowerShell with wusa (windows update standalone installer) and it eats .msu files gladly.

But wait, the hotfixes is in a self-extractor exe with at least for some no command-line way to automate, BAD!! So PowerShell to the rescue again, and here on this blog post I found a guy making a PS function to unzip an archive file and it works on the hotfix.EXE also!

Screen Shot 2013-09-13 at 20.18.45
Get-Item .\* | %{Expand-ZipFile -FilePath $_.FullName -OutputPath c:\hotfixes}

And then we can use the WUSA and that wrapped in a foreach with a little while loop to handle that not a  new wusa starts before the preceding one is done as it cannot be run several instances simultaneously (maybe there is a better way to do this of course but this works 😉 )

Screen Shot 2013-09-13 at 14.38.17
Get-Item c:\hotfixes\* | foreach {WUSA ""$_.FullName /quiet /norestart"";while(get-process wusa){Write-Host "Installing $_.Name"}}

And to see if your hotfixes has been installed you can use the following command

check-hotfixesinstalled
Get-HotFix | Where Description -match hotfix

(Get-HotFix | Where Description -match hotfix).count

and of course after installing the hotfixes we need to reboot 🙂

Comments

[…] nice? Well, the script is partly built on the ideas of Niklas Åkerlund, a fellow Swede, on howto install multiple Windows hotfixes. Using a forum-post response by Michael […]

Leave a comment

name*

email* (not published)

website