With the release of Windows Server 2008 R2, Hyper-V added the capability to get the IP address assigned to a Virtual Machine from the Host KVP items. In order to get this IP address you need the latest integration services installed inside the virtual machine.
FYI, VMM does not currently expose these IP Addresses, but this is something that you will see in VMM in the future for sure.
To get these IP Addresses and other KVP items follow these steps.
Open notepad and copy the contents below into a filed called Get-HyperVKVP.ps1. You can simply edit the value of the $vm and run this PowerShell script as an administrator locally on the Hyper-V server. It will give you all the KVP's associated with the virtual machine, including the IP Address. See below for an example output.
<<
$vm = "<enter the friendly name of a virtual machine";
filter Import-CimXml{ $CimXml = [Xml]$_ $CimObj = New-Object -TypeName System.Object foreach ($CimProperty in $CimXml.SelectNodes("/INSTANCE/PROPERTY")) { if ($CimProperty.Name -eq "Name" -or $CimProperty.Name -eq "Data") { $CimObj | Add-Member -MemberType NoteProperty -Name $CimProperty.NAME -Value $CimProperty.VALUE } } $CimObj}
$VmObj = Get-WmiObject -Namespace root\virtualization -Query "Select * From Msvm_ComputerSystem Where ElementName='$vm'"$KvpObj = Get-WmiObject -Namespace root\virtualization -Query "Associators of {$VmObj} Where AssocClass=Msvm_SystemDevice ResultClass=Msvm_KvpExchangeComponent"
$KvpObj.GuestIntrinsicExchangeItems | Import-CimXml
>>
PS C:\Users\Admin\Desktop> .\Get-HyperVKVP.ps1
Data Name---- ----WIN-D8R7D2893P8 FullyQualifiedDomainNameWindows Server 2008 R2 Enterprise OSName6.1.7600 OSVersion CSDVersion6 OSMajorVersion1 OSMinorVersion7600 OSBuildNumber2 OSPlatformId0 ServicePackMajor0 ServicePackMinor274 SuiteMask3 ProductType10 OSEditionId9 ProcessorArchitecture6.1.7600.16385 IntegrationServicesVersion169.254.159.251;172.30.169.167 NetworkAddressIPv4fe80::c188:6b14:d667:9ffb%18;2001:4898:2c:3:c9fd:e7ae:f2... NetworkAddressIPv6 RDPAddressIPv4 RDPAddressIPv6