Search code examples
ip-addresspowershell-3.0hyper-v

how to get IP address of all virtual machines running on hyper V


is there any way to get IP addresses of all running Virtual machines with PowerShell? I have tried the following

Get-VM | ?{$_.State -eq "Running"} | Select -ExpandProperty networkadapters

Get-VM | ?{$_.State -eq "Running"} | Get-VMNetworkAdapter | Select VMName, IPAddresses

I am able to get list of virtual machines but I'm not getting any IP addresses for them


Solution

  • There's an answer to your question by the Ed Wilson, "The Scripting Guy" here:

    https://blogs.technet.microsoft.com/heyscriptingguy/2013/04/24/use-powershell-to-get-name-and-ip-address-of-virtual-machines/

    Adapting it to your case:

    get-vm | ?{$_.State -eq "Running"} | select -ExpandProperty networkadapters | select vmname, macaddress, switchname, ipaddresses | ft -wrap -autosize
    

    I hope this is still useful.