Listing Virtual Machines and Portgroups

vSphere 5.0 – If you need a list of Virtual Machines and the portgroups they are attached to:

Get-VM -Location "somewhere" | ft Name, @{Expression={$_.NetworkAdapters.NetworkName};Label="Network Name"}

If you need to export this to a CSV:

Get-VM -Location "somewhere" | select-object Name, @{Expression={$_.NetworkAdapters.NetworkName};Label="Network Name"} | export-csv "vm-networks.csv"