KaustubhK
KaustubhK

Reputation: 775

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

Upvotes: 23

Views: 56487

Answers (2)

pgr
pgr

Reputation: 938

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.

Upvotes: 40

Stephen Quan
Stephen Quan

Reputation: 26299

In either PowerShell or Windows Batch, you can use arp -a to list IP addresses of everything on your Windows machine (both real and Hyper-V machines are listed). You can filter on Mac address to get precisely the IP you're looking for.

arp -a | findstr 00-15-5d-19-73-00
  172.17.210.62         00-15-5d-19-73-00     static

Upvotes: 25

Related Questions