ESXi – An oldie but a goodie – CDP info via PowerCLI and Host CLI

When you don’t use something for a while, you tend to forget how valuable it can be.

Even from its very early iterations, ESXi has been able to display CDP information so you can quickly establish “what’s patched where “.  Easy to get from the gui, but far more useful from the shell or cli. This has been valuable to me many times (mostly in remote data centers), and is something I make sure is in my scripts/quicktips cookbook.

The easiest way to see this is directly from the host. You could either ssh in or do it from the dcui using the vim-cmd command and the query_networkhint option;

28-09-2015 9-55-44 PM












Obviously that’s a very verbose output, so to zero in on the actual information use grep with a context setting of 2. This will isolate the output to include the switch hostname devId, The switch IP address and the portId.

29-09-2015 9-56-11 PM








..and of course this can be done remotely from PowerCLI. There’s numerous ways to achieve this, VMware have been kind enough to provide an example here, so I have tweaked this to suit my own requirements, by adding parameters and stripping out checks and data I’m not interested in.

Because it uses parameters, and because it’s based on pure PowerShell, it’s extensible and flexible, so you can retrieve info for a single host, all hosts in a VC server or all hosts in a Cluster, by specifying the -VMhost, -Cluster or -VCServer parameter in the execution.

Here’s the results;

30-09-2015 11-56-38 PM













More data can be included by adding in other available options:  CdpVersion, Ttl, Samples, SoftwareVersion, HardwarePlatform, FullDuplex, Mtu etc etc. It all depends on what data is important to you.

Pipe it through out-file and you have a quick bit of connection documentation, and an easy reference.


Related Post

2 thoughts on “ESXi – An oldie but a goodie – CDP info via PowerCLI and Host CLI

Leave a Reply

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

%d bloggers like this: