Virtu-Al.Net

Virtually everything is poshable

Detailed VMware Host Network Information

Following my previous script ‘Extracting Cisco Discovery Protocol Info‘ I decided to tidy up the script, give a more controlled output and add a few items to the output.

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,
  • Physical Nic Name
  • Speed
  • MAC
  • Switch Device ID
  • Port ID
  • Observed Network ranges
  • VLAN’s

19 Responses to “Detailed VMware Host Network Information”

  • Anonymous says:

    Getting can't index null array on the line

    If ($Hint.Device -eq $vmhost.Config.Network.Pnic[$ <<<< record].

    It seems to loop there. Any suggestions? Also what program did you use to compile this, how do you code this?

  • Anonymous says:

    Please disregard previous comment, I was trying to enter the hostname at the command line

  • Anonymous says:

    I get the following error:

    Unexpected token 'select-Object' in expression or statement.
    At C:\networkinfo.ps1:13 char:42
    + $NetworkInfo = "" select-Object <<<< Host, PNic, Speed, MAC, DeviceID, PortID, Observed, VLAN

  • Virtu-Al says:

    Sorry about that, the blog took some of the formatting out, I have changed it so you should be able to get the working version now.

  • Anonymous says:

    Worked flawless for me… Thank you very much…
    Can you please add the Virtual Switch Name “vSwtich1″ to the table as well? Your Scripts rock, Great job!

  • Wolficool says:

    Hi,

    Great Script!!!

    But how can i Change this script to report this to a Completly Cluster??

  • Virtu-Al says:

    @Wolficool
    Line 4 which starts $vmhosts = Get-VMHost…….

    Change it to $vmhosts = Get-Cluster “MyCluster” | Get-VMHost…..

    That should do the trick ;)

  • Wolficool says:

    Thanks a lot for your help.

    Where do you have all this informations?? I have not seen any book or what else to read more about scripting.

  • Virtu-Al says:

    @Wolficool
    No Problem,

    A good place to start is this post I created a little while ago…

    http://www.virtu-al.net/2009/11/10/powercli-where-do-i-start/

  • Wolficool says:

    Thanks a lot for your Help ;-)

  • amin says:

    i m getting the same error and i did put the host name because i only want to get info from one host. i m connected to the Vcenter
    if i run the commands it do get the in upt to get-view but after that this error. any advise. i m new to this scripting thing.

    $vmhosts = Get-VMHost | Sort Name | Where-Object {$_.State -eq “abcdpr1.abcd.com”} | Get-View
    Getting can’t index null array on the line

    If ($Hint.Device -eq $vmhost.Config.Network.Pnic[$ <<<< record].

    It seems to loop there. Any suggestions? Also what program did you use to compile this, how do you code this?

  • [...] And last but not least, using PowerCLI: [...]

  • Jared Davis says:

    How can we add the port group names to this? IE, the console port names, etc.

  • Jared Davis says:

    I think that would be very helpfull.

  • daunce says:

    Great script. Is it much work to have the vlanid field sorted ascending? at the moment it prints out ” 1 2 3 4″, then next line “4 2 3 1″ etc..

  • Justin says:

    Perfect script… is there a way to add the Network Label as well?

  • Fred says:

    Concerning dvSwitches…. it does show some properties but not d()vSwitch name and PrtInUse

  • Alan says:

    Yeah I know the issue, some of the properties for that object are not the same as Standard vSwitches so it doesnt work properly.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>