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

Hello again!

During the last week I did some test with the script and I realize that is not handy to type a bunch of server names when you need to analyze big Clusters, so i decided to create a V2 of the script specifically for Clusters. I think this will like to lazy people like me that hates to type 16 servers names when all of them belong to the same cluster.

This V2 script only requires the name of the 2012 Hyper-V Cluster you want to analyze and automatically will collect the hotfixes from all nodes and will compare with the list already mentioned in my last post. https://blogs.technet.com/b/cedward/archive/2013/05/24/validating-hyper-v-2012-and-failover-clustering-2012-hotfixes-and-updates-with-powershell.aspx

Here is the V2 script that only requires the Cluster Name

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

June 22h 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)

HyperVCluster2012UpdatesCheck.zip

And here is the code. Enjoy!

    1: param
    2: (
    3:     [parameter(mandatory=$True)]
    4:     $ClusterName
    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 installed Hotfixes from all nodes of the Cluster
   21:  
   22: $ClusterNodes = Get-Cluster $ClusterName |Get-ClusterNode
   23:  
   24: foreach($Node in $ClusterNodes)
   25: {
   26: $Hotfixes = Get-HotFix -ComputerName $Node |select HotfixID,description
   27:  
   28: Write-Host "COLLECTING HOTFIXES ON HYPER-V HOST: " $Node -ForegroundColor Yellow
   29: Write-Host "Listing Hyper-V 2012 Hotfixes" -ForegroundColor Yellow
   30: foreach($RecomendedHotfix in $HyperVHotfixes)
   31: {
   32:         $witness = 0
   33:         foreach($hotfix in $Hotfixes)
   34:         {
   35:                 If($RecomendedHotfix.id -eq $hotfix.HotfixID)
   36:                 {
   37:                     Write-Host "--------------------------"
   38:                     Write-Host "Hyper-V Host: "$Node
   39:                     Write-Host $RecomendedHotfix.Id "installed" -ForegroundColor Green
   40:                     write-host $RecomendedHotfix.Description
   41:                     Write-Host "--------------------------"
   42:                     $witness = 1
   43:                  }
   44:         }  
   45:         if($witness -eq 0)
   46:         {
   47:             Write-Host "--------------------------"
   48:             Write-Host "Hyper-V Host: "$Node
   49:             Write-Host $RecomendedHotfix.Id "not installed" -ForegroundColor Red
   50:             write-host $RecomendedHotfix.Description
   51:             Write-Host "--------------------------"
   52:         }
   53:  
   54: }
   55:  
   56: Write-Host "Listing Failover Cluster 2012 Hotfixes" -ForegroundColor Yellow
   57:  
   58: foreach($RecomendedClusterHotfix in $ClusterHotfixes)
   59: {
   60:         $witness = 0
   61:         foreach($hotfix in $Hotfixes)
   62:         {
   63:                 If($RecomendedClusterHotfix.id -eq $hotfix.HotfixID)
   64:                 {
   65:                     Write-Host "--------------------------"
   66:                     Write-Host "Hyper-V Host: "$Node
   67:                     Write-Host $RecomendedClusterHotfix.Id "installed" -ForegroundColor Green
   68:                     write-host $RecomendedClusterHotfix.Description
   69:                     Write-Host "--------------------------"
   70:                     $witness = 1
   71:                  }
   72:         }  
   73:         if($witness -eq 0)
   74:         {
   75:             Write-Host "--------------------------"
   76:             Write-Host "Hyper-V Host: "$Node
   77:             Write-Host $RecomendedClusterHotfix.Id "not installed" -ForegroundColor Red
   78:             write-host $RecomendedClusterHotfix.Description
   79:             Write-Host "--------------------------" 
   80:         }
   81: }
   82: }