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
Who deleted my VM ? Microsoft NLB Error when trying to Cluster Cloned VM’s











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?
Please disregard previous comment, I was trying to enter the hostname at the command line
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
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.
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!
Added the VSwitch info as requested…. http://teckinfo.blogspot.com/2009/02/more-network-info.html
Hi,
Great Script!!!
But how can i Change this script to report this to a Completly Cluster??
@Wolficool
Line 4 which starts $vmhosts = Get-VMHost…….
Change it to $vmhosts = Get-Cluster “MyCluster” | Get-VMHost…..
That should do the trick
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.
@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/
Thanks a lot for your Help
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: [...]
How can we add the port group names to this? IE, the console port names, etc.
I think that would be very helpfull.
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..
Perfect script… is there a way to add the Network Label as well?
Concerning dvSwitches…. it does show some properties but not d()vSwitch name and PrtInUse
Yeah I know the issue, some of the properties for that object are not the same as Standard vSwitches so it doesnt work properly.