Exporting Hyper-V Client IP Address Details to a CSV

,
1–2 minutes

Originally from

Found, then improved from

Found, then improved

Repost

the wolf taking a little inventory of a row of virtual machine boxes, a lined list pinned to each, one amber, the raven noting it down

Took a file to figure out the correct syntax — the following line will export all of the primary IP Addresses along with the name and mac address in a single PS command

PowerShell
Get-VM | ?{$_.ReplicationMode -ne “Replica”} | Select -ExpandProperty NetworkAdapters | ? IPAddresses -ne $null | % { [PSCustomObject]@{ Name=$_.VMName;IPAddress=$_.IPAddresses[0];MacAddress=$_.MacAddress; } }