Hotfix and updates check of Hyper-V and Cluster with Powershell
I read Hyper-V.nu great blog article about Christian Edwards script that checks both hosts and clusters for hotfixes and updates and found some things I wanted to improve in the script, first of all I wanted an object list instead of just some Write-Host with cool colors.. Then I can use the fabulous techniques of PowerShell to just show the once that I do not have installed or make a decent report for my cluster or just standalone hosts.
The next improvement I thought of was the automatic download of all hotfixes.. Well registering at the web page and downloading each hotfix can work for some but not many, so I extended the XML files with the DownloadURL and also changed the script to support either a host or a cluster object. The download parameter will not check what´s installed or not, it will just download all hotfixes that I found URL´s for so bare with me if it is not complete and make a comment or send me a tweet and I will try to update the xml file
Here you can see how I can run it and also as I have the result as objects filter on installed or not
And here you can see when I check a cluster and also add the parameters for downloading and the path to where the downloaded files shall reside
And here is a screendump of some of the hotfix files that are downloaded, as you can see in the script I utilize the BITS engine to download the files 🙂
Updated with hotfixes to 2013-07-15! Here is the script and the xml files with the extended DownloadURL are in this download zip file-> hyperv12updatescheck.
# Remake of Christian Edwards script to make it more flexible # http://blogs.technet.com/b/cedward/archive/2013/05/31/validating-hyper-v-2012-and-failover-clustering-hotfixes-with-powershell-part-2.aspx # # Niklas Akerlund 2013-06-28 param ( [parameter(ValueFromPipeline=$true, Position=0)] [string]$Hostname, [parameter(ValueFromPipeline=$true, Position=1)] $ClusterName, [switch]$Download, [string]$DownloadPath ) #Getting current execution path $scriptpath = $MyInvocation.MyCommand.Path $dir = Split-Path $scriptpath $listofHotfixes = @() #Loading list of updates from XML files [xml]$SourceFileHyperV = Get-Content $dir\UpdatesListHyperV.xml [xml]$SourceFileCluster = Get-Content $dir\UpdatesListCluster.xml $HyperVHotfixes = $SourceFileHyperV.Updates.Update $ClusterHotfixes = $SourceFileCluster.Updates.update #Getting installed Hotfixes from all nodes of the Cluster/hosts if ($ClusterName){ $Nodes = Get-Cluster $ClusterName | Get-ClusterNode | Select -ExpandProperty Name }else { $Nodes = $Hostname } foreach($Node in $Nodes) { $Hotfixes = Get-HotFix -ComputerName $Node |select HotfixID,description foreach($RecomendedHotfix in $HyperVHotfixes) { $witness = 0 foreach($hotfix in $Hotfixes) { If($RecomendedHotfix.id -eq $hotfix.HotfixID) { $obj = [PSCustomObject]@{ HyperVNode = $Node HotfixType = "Hyper-V" RecomendedHotfix = $RecomendedHotfix.Id Status = "Installed" Description = $RecomendedHotfix.Description DownloadURL = $RecomendedHotfix.DownloadURL } $listOfHotfixes += $obj $witness = 1 } } if($witness -eq 0) { $obj = [PSCustomObject]@{ HyperVNode = $Node HotfixType = "Hyper-V" RecomendedHotfix = $RecomendedHotfix.Id Status = "Not Installed" Description = $RecomendedHotfix.Description DownloadURL = $RecomendedHotfix.DownloadURL } $listofHotfixes += $obj } } foreach($RecomendedClusterHotfix in $ClusterHotfixes) { $witness = 0 foreach($hotfix in $Hotfixes) { If($RecomendedClusterHotfix.id -eq $hotfix.HotfixID) { $obj = [PSCustomObject]@{ HyperVNode = $Node HotfixType = "Cluster" RecomendedHotfix = $RecomendedClusterHotfix.Id Status = "Installed" Description = $RecomendedClusterHotfix.Description DownloadURL = $RecomendedClusterHotfix.DownloadURL } $listOfHotfixes += $obj $witness = 1 } } if($witness -eq 0) { $obj = [PSCustomObject]@{ HyperVNode = $Node HotfixType = "Cluster" RecomendedHotfix = $RecomendedClusterHotfix.Id Status = "Not Installed" Description = $RecomendedClusterHotfix.Description DownloadURL = $RecomendedClusterHotfix.DownloadURL } $listOfHotfixes += $obj } } } if ($Download){ foreach($RecomendedHotfix in $HyperVHotfixes){ if ($RecomendedHotfix.DownloadURL -ne ""){ Start-BitsTransfer -Source $RecomendedHotfix.DownloadURL -Destination $DownloadPath } } foreach($RecomendedClusterHotfix in $ClusterHotfixes){ if ($RecomendedClusterHotfix.DownloadURL -ne ""){ Start-BitsTransfer -Source $RecomendedClusterHotfix.DownloadURL -Destination $DownloadPath } } } $listofHotfixes
Comments
Fantastic work!,
Thanks, it worked awesome and big time saver.
This is awesome.
I have two enhancements requests that would really help us out.
#1 – Add a PowerShell script switch that allows you to specify if you want to check Hyper-V, Windows Clustering, or both. For example we have non-HyperV clusters we would like to use this script for so we are using a single method consistently, and same thing for non-clustered Hyper-V servers.
#2 – Add a PowerShell script switch and XML tag that allows you to filter out Windows Update issued hot fixes. We use WSUS here and so we don’t need to worry about those, and would really just like to focus on what we call “out of band” (meaning not issued through an automated mechanism from Microsoft) hot fixes.
Do you have any plans to potentially host XML files somewhere like an FTP site so we could periodically check to see if there were updates like when there are updates to http://social.technet.microsoft.com/wiki/contents/articles/15576.hyper-v-update-list-for-windows-server-2012.aspx ?
I could make the modifications to the script myself to do these things, but that would be a one off and I figured if we were looking for these features others might be as well (and this is your baby after all).
Thanks for putting this together in the first place!
I somehow missed the script came from a Technet site and you had added to it. I will cross post my request there as well.
Hi Niklas,
I stumpled across your comment on the technet blog _after_ I modified the script exactly as you did with basically the same features. I would be very interested in updating the script as requested in the comment of Dan Sheehan. Are you interested in updating your blogpost with the new script?
BG Christoph
@Christoph
Pingback – http://blog.atwork.at/post/2013/08/27/Hyper-V-Cluster-updaten.aspx
[…] my blog post about checking the hosts for updates and hotfixes I also have added the functionality to download the hotfixes from Microsoft´s […]
Hi,
The updates that show as “not installed”, do I need to install all of them or only if I am having some trouble?
You can read the associated KB and see if you need it. Some of them may not apply to your setup and then you do not need to install them 🙂
For me this script has downloaded “Windows6.1-KB976424-x64” on Windows 2012. This is a 2008R2 patch and not a Windows 2012.
So I noticed, the xml files i took from Christian seems to have that in them, I will update my xml to not include that patch!
Windows8-RT-KB2848344-x64 is obsolete and has been replaced by http://support.microsoft.com/kb/2870270 that is also included.
Hi!
I’ve started new project on GitHub that hosts this script and I currently work to create some improvements – see https://github.com/it-praktyk/Get-WindowsHotfixes .
Today I’ve updated UpdatesListCluster.xml – list of hotfixes for Windows Server 2012 – information about KB2894464 was added.
Please feel free to colaborate.
Wojciech Sciesinski
[…] provided by vNiklas which downloads the updates automatically for me which is just brill (link: http://vniklas.djungeln.se/2013/06/28/hotfix-and-updates-check-of-hyper-v-and-cluster-with-powershel…😉 – but this should be part of Windows Update or Microsoft should be writing a tool for us to make […]
Hi,
do you have similar for Windows 2008 R2 HyperV Platform ?
[…] closing I have the original link for the script in the initial discussion. I also have a method to update your Hyper-V Cluster automatically with a script. That can be pretty […]