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 https://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 # https://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:
# https://blogs.msdn.com/b/virtual_pc_guy/archive/2008/11/18/hyper-v-script-looking-at-kvp-guestintrinsicexchangeitems.aspx
# and
# https://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....
Comments
Anonymous
October 11, 2010
I did the same thing with vb so I could run it out of SCOM. SCOM then raises an alert if the IC version is wrong. Unfortunately I've been unable to update some of my WS08R2 guests. Very frustrating.Anonymous
October 11, 2010
Does this only run on an R2 host with an R2 guest? I've tried on an R2 host with a 2k3 guest, an R1 host on both a R1 guest and an XP guest and in every case I get an error saying the registry key doesn't existAnonymous
October 11, 2010
It will only run on a R2 Host. R1 did not have the registry key. But on R2, it should run with an 2k3 guest. Below is my output. Do you have any Hotfix installed or is your vmguest.iso the RTM version of 2008R2? Guest KVP information for w2k3 FullyQualifiedDomainName w2k3.contoso.com OSName Microsoft Windows Server 2003 OSVersion 5.2.3790 CSDVersion Service Pack 2 OSMajorVersion 5 OSMinorVersion 2 OSBuildNumber 3790 OSPlatformId 2 ServicePackMajor 2 ServicePackMinor 0 SuiteMask 18 ProductType 3 OSEditionId 0 ProcessorArchitecture 0 IntegrationServicesVersion 6.1.7600.20778Anonymous
October 12, 2010
I'm pretty sure that host is up to date with patches, and that the guests are too. I guess it's time for some double checking my endAnonymous
October 21, 2010
The comment has been removedAnonymous
October 26, 2010
The comment has been removedAnonymous
October 26, 2012
I tried running this script on windows 2008 R2 core, however getting an error : You cannot call a method on a null-valued expressi At C:test.ps1:20 char:48
- foreach ($CimProperty in $CimXml.SelectNodes ME='Name']")) + CategoryInfo : InvalidOperation: (S meException + FullyQualifiedErrorId : InvokeMethodOnNull You cannot call a method on a null-valued expressi At C:test.ps1:25 char:48
- foreach ($CimProperty in $CimXml.SelectNodes ME='Data']")) + CategoryInfo : InvalidOperation: (S meException + FullyQualifiedErrorId : InvokeMethodOnNull Any suggestions?
- Anonymous
March 08, 2016
For 2012 the namespace was "rootvirtualization". For 2012 R2 the namespace is now "rootvirtualizationv2"