Hyper-V How To: Check if ICs are Current using Script

Some friends here on the Hyper-V team shared a PowerShell 2.0 script for checking the integration services/integration components to see if they are current in your VMs:

# Test if the IC version is up to date

    [string]$vmName = $(throw "Must specify virtual machine name")

$vm = gwmi -namespace root\virtualization Msvm_ComputerSystem -filter "ElementName='$vmName'"

# Get the associated KVP Exchange component
$kvp = gwmi -namespace root\virtualization `
    -query "Associators of {$vm} where ResultClass=Msvm_KvpExchangeComponent"

# Pull the Guest Intrinsic Exchange Items from XML into a hash
$kvpHash = @{}
    ([xml]("<xml>"+$kvp.GuestInstrinsicExchangeItems+"</xml>")).xml.instance | `

# Save the guest's version
$icVersionGuest = $kvpHash.IntegrationServicesVersion

# Save the host's version
$icVersionHost = (ls 'HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Virtualization\GuestInstaller').`

return -not $icVersionGuest -lt $icVersionHost

For more info on how to use PS cmdlets see: http://www.microsoft.com/technet/scriptcenter/topics/msh/cmdlets/index.mspx

See also James O’Neil’s New and improved PowerShell Library for Hyper-V. Now with more functions and... documentation!

For all 35 sample Hyper-V PS1 scripts in a zipfile, go to: Hyper-V PowerShell Example Scripts.zip-download

Comments (0)

Skip to main content