Hyper-V WMI: KVP Exchange aka Data Exchange (Adding New Items From Guest)
Update 12/5/12
A lot has changed since 2008 and many things have stayed the same… I wanted to provide an update to some of the most commonly viewed posts and this was one of them.
For updated information on this topic please refer to my latest post Customizing The Key Value Pair (KVP) Integration Component.
Original Post
Yesterday’s post (Hyper-V WMI: KVP Exchange aka Data Exchange (Adding New Items From Parent/Host)) showed how to add registry key’s into the guest so that the guest could receive information from the host. Today’s post will show how to add a registry key in the guest so that the host can retrieve it…
Step 1 – Add a registry key to the guest…
Use your faviorite registy editing tool such a reg.exe or powershell.
Examples:
Reg.exe: reg add "HKLM\SOFTWARE\Microsoft\Virtual Machine\Guest" /v test /t REG_SZ /d testing
Powershell: New-ItemProperty -path "HKLM:\SOFTWARE\Microsoft\Virtual Machine\Guest" -name test2 -value testing
Step 2 – Query the value from the host…
This might look very similar to Hyper-V WMI Using PowerShell Scripts – Part 3 (KVP's - Guest OS Version) it is…(just the last line changes :-))
filterImport-CimXml { $CimXml= [Xml]$_ $CimObj=New-Object-TypeNameSystem.Object foreach ($CimPropertyin$CimXml.SelectNodes("/INSTANCE/PROPERTY")) { $CimObj|Add-Member-MemberTypeNoteProperty-Name$CimProperty.NAME-Value$CimProperty.VALUE } $CimObj } $Vm=Get-WmiObject-Namespaceroot\virtualization-Query"Select * From Msvm_ComputerSystem Where ElementName='vista'" $Kvp=Get-WmiObject-Namespaceroot\virtualization-Query"Associators of {$Vm} Where AssocClass=Msvm_SystemDevice ResultClass=Msvm_KvpExchangeComponent" $Kvp.GuestExchangeItems|Import-CimXml |
Output:
Caption : Data : testing Description : ElementName : Name : test Source : 1 Caption : Data : testing Description : ElementName : Name : test2 Source : 1 |
Taylor Brown
Hyper-V Integration Test Lead
https://blogs.msdn.com/taylorb
Comments
Anonymous
July 07, 2008
PingBack from http://blog.a-foton.ru/2008/07/hyper-v-wmi-kvp-exchange-aka-data-exchange-adding-new-items-from-guest/Anonymous
April 10, 2014
Hi, Is there a wmi class which can give us the data that mac1 is mapped to IP1 on network adpater 1. Then mac2 is mapped to IP2 on network adapter 2 and so on and forth. Basically I want a mapping between the mac address and ip address in wmi classes. I know powershell provides this but I need it from wmi. Can you please help