Using PowerShell to get VM IP addresses

Server Man

Well-Known Member
May 17, 2015
Here is a handy PowerShell snippet:

Get-VM | ?{$_.ReplicationMode -ne "Replica"} | Select -ExpandProperty NetworkAdapters | Select VMName, IPAddresses, Status

Which delivers an output like this:



As you can see, it lists the IP addresses of all the virtual machines running under Hyper-V. A couple of notes to make about this:

  • I use Hyper-V Replica heavily. So I have developed the habit of always filtering out Replicas - so I do not worry about them.
  • I look at the network adapter status, because (as you can see) it allows me to tell the difference between a VM without an IP address - and a VM that is not reporting whether it has an IP address or not.

Hopefully you will find this useful in your environments.

Cheers,
Ben

be3c0503a162d3d88834cd99ae2499d8._.gif


Continue reading...
 
Back
Top Bottom