When your network engineer, or other random folks are looking for some assistance in updating their vlan map Visio, or are generally trying to make their work yours (who doesn’t love to delegate) you can bash out this one liner against your VI, and instantly have a list of what VM is on what VLAN.
Yes the formatting sucks, and yes, in my lab I only have a single VLAN (unless someone wants to send me a smart switch), but this gets the point across:
PS C:\Users\bunchc> get-vm | %{ write-host $_.Name `t ($_ | Get-VirtualPortGroup | select vlanid)}
dc01.nerv.local @{VLanId=0}
monitoring.nerv.local @{VLanId=0}
rcli.nerv.local @{VLanId=0}
This Is A Clone @{VLanId=0}
shell.nerv.local @{VLanId=0}
fs.nerv.local @{VLanId=0}
For further network information, all wrapped up in a sexy csv, you can use Alan Renouf’s script here.
Questions? Thoughts? Corrections on my Caca code? Leave me a note in the comments, or hit me up on twitter @cody_bunch
nice and simple and how to get the name with it too?