List SCVMM 2012 R2 virtual machines and sort by NIC

I needed a quick, dirty script to get VMM to spit out its VMs and list them by the adapters they are attached to. Took a few minutes to get it going.

$VMList = Get-vm
$OuttoFile = foreach ($VM in $VMList) {Get-SCVirtualNetworkAdapter -VM $VM | ft Name -AutoSize -GroupBy VMNetwork}
$OuttoFile | Out-File C:\Temp\VM_list1.txt

Leave a Comment

Your email address will not be published.