VMware Cloud Community
DjinjiRinji
Enthusiast
Enthusiast

Detailed VMware Host Network Information

Hello

I am checking my enviroment is properly configured for HA on virtual switches using uplinks connected to differents phisycal switches.

For this I am using Alan script to get a report, its a great script but I am trying to add the management add of DevID and virtual switchs information to know NICs being used by vSS.

Alan script

http://www.virtu-al.net/2008/12/12/detailed-vmware-host-network-information/

I tried to add those 2 lines to get the report just copying line 17 and modified with $NetworkInfo.mgmtaddr but didn't work. CDP information does not show vSS using each NIC.

How can I add these info to report or modify vmware powercli script to get a report as Alan script with this info?

http://kb.vmware.com/selfservice/microsites/search.do?language=en_US&cmd=displayKC&externalId=100706...

Connect-VIServer MYVISERVER
$filename = "c:\DetailedNetworkInfo.csv"
Write "Gathering VMHost objects"
$vmhosts = Get-VMHost | Sort Name | Where-Object {$_.State -eq "Connected"} | Get-View
$MyCol = @()
foreach ($vmhost in $vmhosts){
$ESXHost = $vmhost.Name
Write "Collating information for $ESXHost"
$networkSystem = Get-view $vmhost.ConfigManager.NetworkSystem
foreach($pnic in $networkSystem.NetworkConfig.Pnic){
     $pnicInfo = $networkSystem.QueryNetworkHint($pnic.Device)
     foreach($Hint in $pnicInfo){
         $NetworkInfo = "" | select-Object Host, PNic, Speed, MAC, DeviceID, PortID, Observed, VLAN
         $NetworkInfo.Host = $vmhost.Name
         $NetworkInfo.PNic = $Hint.Device
         $NetworkInfo.DeviceID = $Hint.connectedSwitchPort.DevId
         $NetworkInfo.PortID = $Hint.connectedSwitchPort.PortId
         $record = 0
         Do{
             If ($Hint.Device -eq $vmhost.Config.Network.Pnic[$record].Device){
                 $NetworkInfo.Speed = $vmhost.Config.Network.Pnic[$record].LinkSpeed.SpeedMb
                 $NetworkInfo.MAC = $vmhost.Config.Network.Pnic[$record].Mac
             }
             $record ++
         }
         Until ($record -eq ($vmhost.Config.Network.Pnic.Length))
         foreach ($obs in $Hint.Subnet){
             $NetworkInfo.Observed += $obs.IpSubnet + " "
             Foreach ($VLAN in $obs.VlanId){
                 If ($VLAN -eq $null){
                 }
                 Else{
                     $strVLAN = $VLAN.ToString()
                     $NetworkInfo.VLAN += $strVLAN + " "
                 }
             }
         }
         $MyCol += $NetworkInfo
     }
}
}
$Mycol | Sort Host, PNic | Export-Csv $filename -NoTypeInformation
Kindly mark as solved if your questions are answered.
>>>>>
Guillermo R
LinkedIn: https://www.linkedin.com/in/gramallo
Web: http://bakingclouds.com/
Reply
0 Kudos
2 Replies
LucD
Leadership
Leadership

The mgmtAddr property will show the IP address of the interface used for SNMP management (if it is configured).

See the PhysicalNicCdpInfo object.

Do you see a value for the Management Address entry when you go via the vSphere Client ?

Did your script look something like this ?

Connect-VIServer MYVISERVER 
$filename
= "c:\DetailedNetworkInfo.csv"
Write
"Gathering VMHost objects"
$vmhosts
= Get-VMHost | Sort Name | Where-Object {$_.State -eq "Connected"} | Get-View
$MyCol = @() foreach ($vmhost in $vmhosts){ $ESXHost = $vmhost.Name
Write "Collating information for $ESXHost"
$networkSystem = Get-view $vmhost.ConfigManager.NetworkSystem
foreach
($pnic in $networkSystem.NetworkConfig.Pnic){      $pnicInfo = $networkSystem.QueryNetworkHint($pnic.Device)      foreach($Hint in $pnicInfo){          $NetworkInfo = "" | select-Object Host, PNic, Speed, MAC, DeviceID, PortID, mgmtAddr, Observed, VLAN
         $NetworkInfo.Host = $vmhost.Name
        
$NetworkInfo.PNic = $Hint.Device
         $NetworkInfo.DeviceID = $Hint.connectedSwitchPort.DevId
         $NetworkInfo.PortID = $Hint.connectedSwitchPort.PortId
         $NetworkInfo.mgmtAddr = $Hint.connectedSwitchPort.mgmtAddr
         $record = 0
         Do{              If ($Hint.Device -eq $vmhost.Config.Network.Pnic[$record].Device){                  $NetworkInfo.Speed = $vmhost.Config.Network.Pnic[$record].LinkSpeed.SpeedMb
                
$NetworkInfo.MAC = $vmhost.Config.Network.Pnic[$record].Mac
             }             
$record ++
         }          Until ($record -eq ($vmhost.Config.Network.Pnic.Length))          foreach ($obs in $Hint.Subnet){              $NetworkInfo.Observed += $obs.IpSubnet + " "
            
Foreach ($VLAN in $obs.VlanId){                  If ($VLAN -eq $null){                  }                  Else{                      $strVLAN = $VLAN.ToString()                      $NetworkInfo.VLAN += $strVLAN + " "
                 }              }          }          $MyCol += $NetworkInfo
     } } } $Mycol | Sort Host, PNic | Export-Csv $filename -NoTypeInformation


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

Reply
0 Kudos
DjinjiRinji
Enthusiast
Enthusiast

Yes, had a typo error in '$NetworkInfo.mgmtAddr' and my line 13 was

'$NetworkInfo = "" | select-Object Host, PNic, Speed, MAC, DeviceID, PortID, Observed, VLAN, mgmtAddr'

This is working now..

What object can be used to get NICs used by each vSS? Object PhysicalNicCdpInfo does not have that option.

My intention of this report is analyse the vSS configuration for HA using different network adapters and physical switches reading this report.

Thanks Luc

Kindly mark as solved if your questions are answered.
>>>>>
Guillermo R
LinkedIn: https://www.linkedin.com/in/gramallo
Web: http://bakingclouds.com/
Reply
0 Kudos