Share via


Validating Hyper-V 2012 and Failover Clustering 2012 Hotfixes and updates with Powershell

Hi! I know I didn’t write anything for a long time but now I am back again. The good thing about this long “silence” on my blog is that I’ve been really busy helping customers to deploy Windows Server 2012 Hyper-V. This is awesome because the general feeling is that this version is probably the best Hypervisor on the market today. Of course this is a personal opinion and may be influenced by the fact that I work for Microsoft, but it is also true that probably now is the first time I can say it proudly.

Today I want to share with you a really simple Powershell script that detects if your Hyper-V 2012 hosts have installed the updates listed on the TechNet Wiki site that the Product group is updating regularly. The Wiki Site is this one : https://social.technet.microsoft.com/wiki/contents/articles/15576.hyper-v-update-list-for-windows-server-2012.aspx

Also, the same Powershell script detects if the Failover Cluster 2012 updates listed on this KB article are installed https://support.microsoft.com/kb/2784261. This KB article is also maintained by the PG, so I really encourage you to add both links in your favorites.

UPDATE: Carlos Mayol from our PFE Virtualization team pointed me to this Wiki article as well. https://social.technet.microsoft.com/wiki/contents/articles/15577.list-of-failover-cluster-hotfixes-for-windows-server-2012.aspx, so I’ve updated the Cluster XML file to also check these hotfixes . Thank you Carlos ;)

June 6th 2013 UPDATE: XML files have been updated to include the latest changes and updates from the wiki site.

June 22th 2013 UPDATE: XML files have been updated to include the latest changes and updates from the wiki site.

July 15th 2013 UPDATE: XML files have been updated to include the latest changes and updates from the wiki site.

September 24th 2013 UPDATE: XML files have been updated to include the latest changes and updates from the wiki site. (This rollup is important because includes hotfix 2877211 to properly collect disc latency information with perfmon)

HyperV2012UpdatesCheck.zip

The script load 2 XML files content with the list of the hotfixes for Hyper-V and Cluster (I decided two keep them separate for consistency) and then compares this list with the installed hotfixes on your Hyper-V host. I will keep the XML files up to date so come back here for the latest version in the future. The current version of the script includes hotfixes listed on May 24th 2013.

The output is simple and you will quickly see if you need to install some of them or your hosts are up to date. (Please read if the hotfix applies to your environment based on the comments from the links mentioned before)

One last thing! You can specify more than one server to analyze separating the names with “comas” but will require to have permissions to collect the information remotely. The last consideration is that you must unzip the XML and the PS1 files on the same folder. The script will load the XML files content from the current path of the script.

The syntax to execute the script is

"c:\folder\HyperV2012UpdatesCheck.ps1 server1,server2,serverX..”

  image

And here you have the code in case you want to take a look before running it.

    1: param
    2: (
    3:     [parameter(mandatory=$True)]
    4:     [String[]]$HyperHostName
    5:     
    6: )
    7:  
    8: #Getting current execution path
    9: $scriptpath = $MyInvocation.MyCommand.Path
   10: $dir = Split-Path $scriptpath
   11:  
   12: #Loading list of updates from XML files
   13:  
   14: [xml]$SourceFileHyperV = Get-Content $dir\UpdatesListHyperV.xml
   15: [xml]$SourceFileCluster = Get-Content $dir\UpdatesListCluster.xml
   16:  
   17: $HyperVHotfixes = $SourceFileHyperV.Updates.Update
   18: $ClusterHotfixes = $SourceFileCluster.Updates.update
   19:  
   20: #Getting Hotfixes installed on the specified Hyper-V Host
   21:  
   22: foreach($VMHost in $HyperHostName)
   23: {
   24: $Hotfixes = Get-HotFix -ComputerName $VMHost |select HotfixID,description
   25:  
   26: Write-Host "COLLECTING HOTFIXES ON HYPER-V HOST: " $HyperHostName -ForegroundColor Yellow
   27: Write-Host "Listing Hyper-V 2012 Hotfixes" -ForegroundColor Yellow
   28: foreach($RecomendedHotfix in $HyperVHotfixes)
   29: {
   30:         $witness = 0
   31:         foreach($hotfix in $Hotfixes)
   32:         {
   33:                 If($RecomendedHotfix.id -eq $hotfix.HotfixID)
   34:                 {
   35:                     Write-Host "--------------------------"
   36:                     Write-Host "Hyper-V Host: "$VMHost
   37:                     Write-Host $RecomendedHotfix.Id "installed" -ForegroundColor Green
   38:                     write-host $RecomendedHotfix.Description
   39:                     Write-Host "--------------------------"
   40:                     $witness = 1
   41:                  }
   42:         }  
   43:         if($witness -eq 0)
   44:         {
   45:             Write-Host "--------------------------"
   46:             Write-Host "Hyper-V Host: "$VMHost
   47:             Write-Host $RecomendedHotfix.Id "not installed" -ForegroundColor Red
   48:             write-host $RecomendedHotfix.Description
   49:             Write-Host "--------------------------"
   50:         }
   51:  
   52: }
   53:  
   54: Write-Host "Listing Failover Cluster 2012 Hotfixes" -ForegroundColor Yellow
   55:  
   56: foreach($RecomendedClusterHotfix in $ClusterHotfixes)
   57: {
   58:         $witness = 0
   59:         foreach($hotfix in $Hotfixes)
   60:         {
   61:                 If($RecomendedClusterHotfix.id -eq $hotfix.HotfixID)
   62:                 {
   63:                     Write-Host "--------------------------"
   64:                     Write-Host "Hyper-V Host: "$VMHost
   65:                     Write-Host $RecomendedClusterHotfix.Id "installed" -ForegroundColor Green
   66:                     write-host $RecomendedClusterHotfix.Description
   67:                     Write-Host "--------------------------"
   68:                     $witness = 1
   69:                  }
   70:         }  
   71:         if($witness -eq 0)
   72:         {
   73:             Write-Host "--------------------------"
   74:             Write-Host "Hyper-V Host: "$VMHost
   75:             Write-Host $RecomendedClusterHotfix.Id "not installed" -ForegroundColor Red
   76:             write-host $RecomendedClusterHotfix.Description
   77:             Write-Host "--------------------------" 
   78:         }
   79: }
   80: }

Comments

  • Anonymous
    January 01, 2003
    June 6th 2013 UPDATE: XML files have been updated to include the latest changes and updates from the wiki site.

  • Anonymous
    January 01, 2003
    Very good script. Thanks a lot.

  • Anonymous
    January 01, 2003
    I feel that this is very useful script but I can't try it because there aren't xml files by the download link:). There's only ps1 file...

  • Anonymous
    January 01, 2003
    Hi guys, I have upload the zip file again that includes the XML files. Please check it again.

  • Anonymous
    January 01, 2003
    Sorry, I post my question 5 minutes later without refresh and Anatoly post the same :-)

  • Anonymous
    January 01, 2003
    Excellent work, Cristian!! Very useful!

  • Anonymous
    June 08, 2013
    Cristian, I just updated the list of Hyper-V hotfixes on the wiki page. Have a look; probably need to make some XML updates :)

  • Anonymous
    June 11, 2013
    Hi, I am looking for xml files. The link for download contain only 5040.HyperV2012UpdatesCheck_081871D1.ps1 script. No .zip file with xml files. "You can download it from here:" is blank. Is it correct?

  • Anonymous
    June 11, 2013
    The comment has been removed

  • Anonymous
    June 19, 2013
    Thanks Cristian for sharing your knowledge and for the useful script :-)

  • Anonymous
    July 01, 2013
    Great script, I have added some object and download stuff in this vniklas.djungeln.se/.../hotfix-and-updates-check-of-hyper-v-and-cluster-with-powershell keep up the good work!

  • Anonymous
    July 30, 2013
    The comment has been removed

  • Anonymous
    September 04, 2013
    Hi Cristian, Could you tell me how to update the xml files so we can do this manually and avoid waiting for your updates? Thanks!

  • Anonymous
    October 09, 2013
    Does your script check for updates applicable to Windows Server 2012 R2?

  • Anonymous
    October 15, 2013
    Windows Server 2012 R2 will have no hotfixes at the moment

  • Anonymous
    November 17, 2013
    Hi! I’ve started new project on GitHub that hosts this script and I currently work to create some improvements – seegithub.com/.../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

  • Anonymous
    January 07, 2014
      ** Newly updated to include 2012 R2 Best Practices. See 11/03/2013 blog regarding R2 updates by

  • Anonymous
    January 21, 2014
    Cracking work thanks :-)

  • Anonymous
    February 09, 2014
    Hi, Can we get the PS for win 2012 R2 servers? Jafar

  • Anonymous
    February 11, 2014
    Is there a 2012 R2 version available?

  • Anonymous
    May 30, 2014
    it's been a while since this has been updated even on github

  • Anonymous
    May 31, 2014
    Hey there,
    If you were aware of my most excellent friend Cristian Edwards’ Hyper-V and Failover

  • Anonymous
    February 20, 2015
    Thanks Cristian. Very useful, because the script structure could be used or updated editing the xml and be used as a recurrent operational task with other critical updates.

  • Anonymous
    April 25, 2015
    Are the XML's up to date at present? (2015-04-25)

  • Anonymous
    August 31, 2015
    Does this script works against Win 2012 R2 or just plain 2012?