Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I tried to take from the Hyper-V (Hyper-V 2012) node with this command the IP address:

Get-VM | select -ExpandProperty networkadapters | select vmname, ipaddress

The thing is that i take as an output only the assigned Private IP addresses and not the Public IP addresses that some VMs have. Any idea why i have this problem?

Also is there any way to take in the same output and the Vlan ID that i have in my VM settings? To get the Vlan from a specific VM i can do it with this

Get-VM 'Name of the VM' | Get-VMNetworkAdapterVlan | select AccessVlanId

All of these things are on Hyper-V 2012 i want also this for Hyper-V 2008 R2. So some changes to the commands maybe required.

share|improve this question
    
What PowerShell package are you using? Hyper-V 2008R2 doesn't come with any PowerShell modules and the SCVMM modules don't provide properties called networkadapters, vmname, and ipaddress. –  longneck Aug 27 '13 at 18:38
    
@longneck You don't need SCVMM modules, and i didn't use SCVMM modules, but the built-in hyper-v modules. I am on a Hyper-V node. As i told i take output with IPs. The problem is "The thing is that i take as an output only the assigned Private IP addresses and not the Public IP addresses that some VMs have. Any idea why i have this problem?" –  ankso Aug 28 '13 at 11:52
    
@longneck you are right, Hyper-V 2008R2 doesn't support this.. I edited my post. If you have now any idea, i would be glad to hear it. –  ankso Aug 28 '13 at 11:55
    
Are the "Public IP's" actually assigned on the adapters in the VM, or are they assigned on a firewall and being NAT'ed? –  longneck Aug 28 '13 at 13:07
    
@longneck No there are assigned on the network adapter inside the VM. –  ankso Aug 28 '13 at 13:23

2 Answers 2

Not having Hyper-V 2012 available for me to test with, I can at least address the PowerShell part of your question:

Get-VM | select -ExpandProperty networkadapters |
    Foreach-Object {
        $_ | AddMember -MemberType NoteProperty -Name VLAN -PassThru
            -Value ($_ | Get-VMNetworkAdapterVlan).AccessVlanID
    } | ft vmname, ipaddress, vlan
share|improve this answer

I hate to just throw in links here, but you should look into James O'neils PowerShell library for Hyper-V 2008R2. Could save you some time.

pshyperv.codeplex.com

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.