VMware Powercli: Check and enable CDP (Cisco Discovery Protocol

Hi,

ESXi has the ability to respond to CDP requests.

Check if CDP is enabled on a vSwitch

PS D:\> $vSwitch=Get-VirtualSwitch -Name vSwitch0 -VMHost myESXiHost.myDomain.org
PS D:\> $vSwitch.ExtensionData.Spec.Bridge.LinkDiscoveryProtocolConfig
Protocol Operation
-------- ---------
cdp      listen

Possible values: down (disable CDP), listen (only respond to client requests), advertise (send frequently advertisments), or both (listen and advertise)

Disable CDP

PS D:\> $oESXCli=Get-EsxCli -VMHost myESXiHost.myDomain.org -V2
PS D:\> $oESXCli.network.vswitch.standard.set.Invoke(@{"vswitchname"="vSwitch1";"cdpstatus"="down"})

To enable both, listing and advertising

PS D:\> $oESXCli.network.vswitch.standard.set.Invoke(@{"vswitchname"="vSwitch1";"cdpstatus"="both"})

ENable both via esxcli.

esxcfg-vswitch -b vSwitch1
esxcli network vswitch standard set -v vSwitch1 -c both

Get CDP information in a Windows VM

PS D:\> Install-Module PSDiscoveryProtocol
PS D:\> $Packet=Invoke-DiscoveryProtocolCapture -Type CDP -force
PS D:\> Get-DiscoveryProtocolData -Packet $packet | ft Computer,Connection,VLAN,Device,Port,Interface -AutoSize

Michael

Leave a Reply