Stay Current! :Detect Hyper-V 2012 Hotfixes if they are installed or not

After reading Cristians excellent blog here --> I decided to try and write an addition on to his original script where it would parse the html table directory from the wiki page and just take the current patches!


so here is my attempt :)





Runs a Check on a remote server for the necessary hotfixes




This script will check technet against the current
"hotfix" list


 .PARAMETER Computername




 .\CheckHotFix.ps1 -Computername Server01







function checkhotfix([string]$computername)


    #List All Patches and & Hotfixes From
Remote Server

    $session = 

    $us = $session.CreateUpdateSearcher()

    $qtd = $us.GetTotalHistoryCount()

    $hot = $us.QueryHistory(1, $qtd)

    $patches = $hot |select title


    #Path for temp file to change large
string into Array of objects

    $temppath = $env:userprofile +

    $tempfile = $temppath +


    #Create a new Com object to work
with internet explorer in hidden mode     

    $ie = new-object -com



    $doc = $ie.document

    sleep 5

    $doc = $ie.document


    $tb1 =
$doc.getelementsbytagname("table") |%{$_.InnerHtml}


    #exporting first table which is the
Current updates

    $tb1[0] |out-file $tempfile


    #importing so we can process as an array

    [array]$in = get-content $tempfile

    remove-item $tempfile

    [array]$heading = $null

    [array]$output = $null

    [array]$kbs = $null


    for($i=0;$i -ne $in.count;$i++)


    if (($in[$i] -notlike "*tr style*") -or ($in[$i]
-notlike "<tbody>") -or ($in[$i] -ne $null))


    if ($in[$i] -like "<td style*")



    $heading +=


    elseif ($in[$i] -like "<td>*")



$count = 0

$returnobj = new-object psobject


    while($in[$i] -ne "</tr>")




if ($in[$i] -like "<td>*")



$item = ($in[$i].split(">")[1]).split("<")[0]


-like "KB*")


$kbtemp = ($item.split(":")[0]).replace(" ","")

$installed = $patches |select-string $kbtemp


($installed -eq $null)



|add-member -type Noteproperty -name "Installed" -value $false





$returnobj |add-member -type Noteproperty -name "Installed" -value







$returnobj |add-member -type noteproperty -name $heading[$count] -value $item







    $output += $returnobj











checkhotfix $computername