Today, if you are using VMM, you can quickly and easily find out if your VM has the integration components installed by using this simple PowerShell script.
<<
PS D:\Windows\system32> get-vm | select name, hostname, hasvmadditions, vmaddition | format-list
Name : vmonmlmichHostName : car-1.contoso.comHasVMAdditions : FalseVMAddition : Not Detected
Name : win2k8r2HostName : AMUNRA.contoso.comHasVMAdditions : TrueVMAddition : Detected>>
The problem is that VMM does not give you the version information for the Integration Components in Hyper-V. if you would like to get that data, you need to use the Msvm_KvpExchangeDataItem property. Below is a script and its output that gives you all that data for all Running VMs with Integration Components installed in Hyper-V.
Option Explicit
Dim WMIServiceDim KvpComponents Dim VMListDim VM Dim itemDim componentDim xmlDim nodeValueDim nodeName
'Create the XML componentSet xml = createObject("MSXML2.DOMDOCUMENT.3.0")
'Get instance of 'virtualization' WMI service on the local computerSet WMIService = GetObject("winmgmts:\\.\root\virtualization")
'Get all the MSVM_ComputerSystem objectSet VMList = WMIService.ExecQuery("SELECT * FROM Msvm_ComputerSystem") For Each VM In VMList if VM.Caption = "Virtual Machine" then WScript.Echo "========================================" WScript.Echo "VM Name: " & VM.ElementName WScript.Echo "VM GUID: " & VM.Name WScript.Echo "VM State: " & VM.EnabledState if VM.EnabledState <> 2 then Wscript.Echo "VM is not in a running state, so no KVPs can be exchanged" end if
' Get the list of KvpComponents Set KvpComponents = WMIService.ExecQuery("SELECT * FROM Msvm_KvpExchangeComponent") '.ItemIndex(0)
For Each component in KvpComponents
' ensure that we are displaying the correct settings for the VM based on its instance ID/Name If UCase(component.SystemName) = UCase(VM.Name) then
Dim GuestItems GuestItems = component.GuestIntrinsicExchangeItems ' Now enumerate the Msvm_KvpExchangeDataItem's that are in XML format For Each item In GuestItems
xml.async = false xml.resolveExternals = false xml.validateOnParse = false xml.loadXML item
If xml.parseError.errorCode Then Wscript.Echo "--> Xml Document Parse Error: " & vbcrlf & _ " Reason = " & xml.parseError.reason & vbcrlf & _ " Line = " & xml.parseError.line & vbcrlf & _ " linePos = " & xml.parseError.linePos & vbcrlf & _ " srcText = " & xml.parseError.srcText & vbcrlf & _ " ErrorCode = " & xml.parseError.ErrorCode & vbcrlf 'WScript.quit Else xml.setProperty "SelectionLanguage", "XPath" set nodeName = xml.selectSingleNode("//INSTANCE/PROPERTY[@NAME='Name']") set nodeValue = xml.selectSingleNode("//INSTANCE/PROPERTY[@NAME='Data']") Wscript.Echo nodeName.Text & " --> " & nodeValue.Text End If
Next End If Next
end ifNext>>
Here is some example output as well. The Integration components version is the IntegrationServicesVersion property:
========================================VM Name: win2k8r2VM GUID: 1D157259-F91F-4C61-8A1E-72F2C5BC112DVM State: 2FullyQualifiedDomainName --> MLMICH-WIN2K8-1.contoso.comOSName --> Windows Server 2008 R2 EnterpriseOSVersion --> 6.1.7056CSDVersion -->OSMajorVersion --> 6OSMinorVersion --> 1OSBuildNumber --> 7056OSPlatformId --> 2ServicePackMajor --> 0ServicePackMinor --> 0SuiteMask --> 274ProductType --> 3OSEditionId --> 10ProcessorArchitecture --> 9IntegrationServicesVersion --> 6.1.7056.0NetworkAddressIPv4 --> 172.30.181.72NetworkAddressIPv6 --> 2001:4898:2a:3:8531:2f57:144c:3ce8;fe80::8531:2f57:144c:3ce8%14;2001:4898:0:fff:0:5efe:172.30.181.72;fe80::5efe:172.30.181.72%15RDPAddressIPv4 --> 172.30.181.72RDPAddressIPv6 --> 2001:4898:2a:3:8531:2f57:144c:3ce8;fe80::8531:2f57:144c:3ce8%14;2001:4898:0:fff:0:5efe:172.30.181.72;fe80::5efe:172.30.181.72%15========================================
>>