Sometimes I wish you could add more fields to the Hyper-V Console, like MAC Addresses or IP Addresses.
As always, PowerShell to the rescue!
Here’s a quick tip to get a list of virtual machines on a Hyper-V host, along with the MAC addresses and IP addresses.
Here’s the PowerShell code:
Get-VM | Select -ExpandProperty NetworkAdapters | Select VMName, MACAddress, IPAddresses
And here are the results:
As you can see from the screen shot above, only *running* VMs show IP addresses.
Want to take it a step further and see which VMs are running Legacy NICs and which VMs have Synthetic NICs? Even virtual switch names?
Easy enough – just lose the second filtering statement.
Get-VM | Select -ExpandProperty NetworkAdapters
And this one is for Stanley…
Need a list of which VHDs are attached to which VM?
Get-VM | Get-VMHardDiskDrive | Select-Object -Property VMName, VMID, ComputerName, ControllerType, ControllerNumber, ControllerLocation, Path | Sort-Object -Property VMName | Out-GridView -Title "Virtual Disks"
Source: PowerShell blog & Keith Mayer’s blog
One Reply to “PowerShell Tip – Get List of VMs, MACs, IPs & VHDs”
Is it possible to get the size of allocated VHDs? Thanks