More Network Info

Following my previous network information script I was asked to add the VSwitch, so here it is…

The following script will add some nice host network information into an object which is exported to a csv file for passing to the network guys or can be used to find your server in that mess of cables that are always meaning to be tidied in the data center.

You will get:

  • Host
  • VSwitch
  • VSwitch Ports (Added for @gabvirtualworld)
  • VSwitch Ports in use (Added for @gabvirtualworld)
  • Physical Nic Name
  • Speed
  • MAC
  • Switch Device ID
  • Port ID
  • Observed Network ranges
  • VLAN’s

Missing anything ?!
Sample output:
SampleNetworkInfo

24 thoughts on “More Network Info”

  1. I am trying to capture vDS Monitoring Port State information to report on traffic usage. Where am I missing this information? I would like to capture and display the current Unicast – ingress and egress trafficvalues.

  2. I’m new to using scripting, so these may sound like dumb questions. How do I execute this script? Do I put the name changes for the hosts in first or does the script prompt for the server names?

  3. I recently sent a reply about running this script on a standalone host. I have an edit: In case the variable has the FDQN you will need to first strip the FDQN of the domain then add the wild card. Then the script will run in all senarios of standalone and vcenter.

    $NetworkInfo.vSwitch = Get-Virtualswitch -VMHost (Get-VMHost ($vmhost.Name.Split(“.”)[0] + “*”)) | where {$_.Nic -eq ($Hint.Device)}

  4. I was having issues running the script against a standalone ESXi host. The problem was with the name of the ESXi host in the following line. I added the wild card to make it work. Hope this helps. Thanks for composing such a useful script.

    ORG:
    $NetworkInfo.vSwitch = Get-Virtualswitch -VMHost (Get-VMHost ($vmhost.Name)) | where {$_.Nic -eq ($Hint.Device)}

    NEW:
    $NetworkInfo.vSwitch = Get-VDSwitch -VMHost (Get-VMHost ($vmhost.Name + “*”)) | where {$_.Nic -eq ($PNic.Device)}

  5. Any chance that you could update this script to use the get-vdswitch cdmlet? I get an error stating that the get-virtualswitch cmdlet is depreciated.

  6. Hi Alan, thanks for this script… Is it possible to get the physical adapter name/model to see virtual switches are configured across different adapters for HA? In my case I have 4 NICs per adapter Regards

  7. Has anyone been able to get Duplex, port group and full VLAN info into this? The VLAN part of this only gets the first VLAN it sees.

    Thanks

  8. great script!
    Is it possible to add the load balancing setting for each vswitch? Ip_hash, src_id etc? I’ve been trying to do this myself but not having much luck so far.

  9. Something that would be useful to add, in addition to number of vSwitch ports, is the number of vSwitch ports that are still available. While this hasn’t been much of a problem since the ESX 2.x days (when there were only 32 ports per vSwitch – period) – I can certainly see it becoming more of an issue as people are beginning to stack up 50, 60, or more VMs per host…

  10. Iben, Thanks for your kind words, you have some great Ideas there, something for me to tackle when I return from VMworld.

    I like the idea of turning it into a tool, might even add a GUI, I have been looking for an excuse to try PrimalForms.

    The other additions are great, they will definately be added.

  11. Well, since you’re asking for feedback – it would be great to see the load balancing method (# “Route based on originating virtual port ID”, “Route based on source MAC hash”, “Use explicit failover order”, or “Route based on ip hash”) and link failure detection method (Beacon or Link).

    This should be listed for each vSwitch and the port groups should list if they use the vSwitch settings or if it is being overridden.

    Also for the vSwitch and port groups if each vmnic is active or standby.

    I wonder if we can use this to make a tool like RANCID http://en.wikipedia.org/wiki/RANCID?

    I like your blog. Keep up the great work. very useful. Thanks!

    I b e n

  12. Hi, I just noticed something very interesting. This script actually gives the “observed” VLANs, not just the port group VLAN IDs you set on the vSwitches. This is something that you can’t get from your VI client (it only provides observed IP ranges). Looking at the code, I assume that it doesn’t get this via CDP, but from listening to the traffic. Obviously you have to be careful with this type of data, however I think this is a real bonus to the tool. Very useful for troubleshooting network issues! Thanks

  13. OK, very weird. I just ran it again and its fine. Please ignore this (and delete the post if you like), while I try to figure out what was different).

  14. That’s strange, as you can see from my sample output there are hosts with nics not attached to VSwitches and it continues on.

  15. There seems to be a bit of a bug. When I run the script it runs fine until it gets to host, where one of the vmnics is not assigned to a vSwitch. From that point on it just duplicates the details of the last port down the spreadsheet.
    Try removing a vmnic from one of your hosts and run it again.

Leave a Reply