Here is where the fun began.
After our network migration we needed to update our documentation for which VMware hosts physical NIC's are plugged into which switch port. I believe the best way to get this info is from power-shell. So I did some hunting and found a script that was close to what I needed and modified it to my needs. (Thanks IT Walk Thru)
Below is what I came up with.
Now when my network team adds a VLAN, I can tell them which switch ports to apply it too.
Hope this helps someone.
Heath
- #create an output array
- $MyCollection = @()
- Connect-VIServer VitualCenter-ServerName
- #Filter out non-connected Hosts
- $vmh = Get-VMHost -State "Connected" | sort
- Get-View $vmh | `
- foreach( $hint in $pnicInfo ){
- if ( $hint.LLDPInfo ) {
- $results = New-Object –TypeName PSObject
- $results | Add-Member –MemberType NoteProperty –Name ESXHostName –Value $esxname
- $results | Add-Member –MemberType NoteProperty –Name DeviceName –Value $physnic.Device
- $results | Add-Member –MemberType NoteProperty –Name PortID –Value $hint.LldpInfo.PortId
- $results | Add-Member –MemberType NoteProperty –Name PortName –Value $hint.LldpInfo.Parameter[4].value
- $results | Add-Member –MemberType NoteProperty –Name SwitchName –Value $hint.LldpInfo.Parameter[6].value
- $MyCollection += $results
- }
- }
- }
- }
- $MyCollection | Export-Csv C:\Scripts\vmwarePnic.csv