A script to check the Integration Services Version on Hyper-V Host and Guests

Hi,

Scripting time again!

Really often, I need to check if the Integration Services Version of the Hyper-V guests are up to date. Some Updates für Hyper-V update the vmguest.iso on the Host. So you need to manually go the VM's afterwards and install the Integrations services again.

To check the "Comprehensive list of Hyper-V R2 updates" go to  http://technet.microsoft.com/en-us/library/ff394763(WS.10).aspx

The Integration Services Version as of this writing is "6.1.7600.20778"

The script below is a extension to # http://blogs.msdn.com/b/virtual_pc_guy/archive/2008/11/18/hyper-v-script-looking-at-kvp-guestintrinsicexchangeitems.aspx which displays the Version of each running guest, and also displays which Integration Services Version is currently offered on the Host.

If you don't see  Integraton Services Version displayed for a VMl, they are certainly not current.

If the Host is up to date, and has a more recent IC Version as your Guests, you might consider an update!

Cheers

Robert

 

 

# Script to determine the IC Version on the Hyper-V Host
# and output KVP Date of the running Guests
# rvi 1.0
# based on:
# http://blogs.msdn.com/b/virtual_pc_guy/archive/2008/11/18/hyper-v-script-looking-at-kvp-guestintrinsicexchangeitems.aspx
# and
# http://social.technet.microsoft.com/wiki/contents/articles/hyper-v-script-to-check-ic-version.aspx
#

 

# Filter for parsing XML data
filter Import-CimXml
{
   # Create new XML object from input
   $CimXml = [Xml]$_
   $CimObj = New-Object -TypeName System.Object
 
   # Iterate over the data and pull out just the value name and data for each entry
   foreach ($CimProperty in $CimXml.SelectNodes("/INSTANCE/PROPERTY[@NAME='Name']"))
      {
         $CimObj | Add-Member -MemberType NoteProperty -Name $CimProperty.NAME -Value $CimProperty.VALUE
      }
 
   foreach ($CimProperty in $CimXml.SelectNodes("/INSTANCE/PROPERTY[@NAME='Data']"))
      {
         $CimObj | Add-Member -MemberType NoteProperty -Name $CimProperty.NAME -Value $CimProperty.VALUE
      }
 
   # Display output
   $CimObj
}
 

## Hostinfo this host
$Server="."
$Hostinfo = Get-WmiObject -class win32_computersystem -computername $Server

Write-Host "Host " $Hostinfo.Name
$HyperVServer = $Hostinfo.Name

# Get the host's ICversion
$icVersionHost = (ls 'HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Virtualization\GuestInstaller').`
    GetValue("Microsoft-Hyper-V-Guest-Installer-Win60-Package")

Write-Host "IC Version on Host" $icVersionHost

$vmList = gwmi -namespace root\virtualization Msvm_ComputerSystem |`
    where{$_.Name -ne $env:COMPUTERNAME}
   
foreach ($vminstance in $vmlist)
{
 
    if ($vminstance.OnTimeInMilliseconds -ne 0)
    {
   
 $VMName = $vminstance.ElementName
 
 # Get the virtual machine object
 $query = "Select * From Msvm_ComputerSystem Where ElementName='" + $VMName + "'"
 $Vm = gwmi -namespace root\virtualization -query $query -computername $HyperVServer
 
 # Get the KVP Object
 $query = "Associators of {$Vm} Where AssocClass=Msvm_SystemDevice ResultClass=Msvm_KvpExchangeComponent"
 $Kvp = gwmi -namespace root\virtualization -query $query -computername $HyperVServer
 
 Write-Host
 Write-Host "Guest KVP information for" $VMName
 
 # Filter the results
 $Kvp.GuestIntrinsicExchangeItems | Import-CimXml
    }
}

#End of script

 

Example Ouput:

PS C:\iccheck> .\iccheck1.ps1
Host HyperVHost1
IC Version on Host 6.1.7600.20778

Guest KVP information for VM2008R2-001

Name Data
---- ----
FullyQualifiedDomainName vm2008r2-001.contoso.com
OSName Windows Server 2008 R2 Standard
OSVersion 6.1.7600
CSDVersion
OSMajorVersion 6
OSMinorVersion 1
OSBuildNumber 7600
OSPlatformId 2
ServicePackMajor 0
ServicePackMinor 0
SuiteMask 16
ProductType 3
OSEditionId 7
ProcessorArchitecture 9
IntegrationServicesVersion 6.1.7600.20542
....

Time to update the Guest....