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)
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..”
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: }