-
Notifications
You must be signed in to change notification settings - Fork 1
/
Get_CDP_Info.ps1
36 lines (36 loc) · 993 Bytes
/
Get_CDP_Info.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# /=======================================================================
# /=
# /= Get_CDP_Info.ps1
# /=
# /= AUTHOR: Jake Bentz
# /= DATE: 08/24/2017
# /=
# /= REQUIREMENTS: N/A
# /=
# /= DESCRIPTION: This script reads CDP info for specified hosts
# /= Twitter: @TripDeezil
# /=
# /= REVISION HISTORY
# /= VER DATE AUTHOR/EDITOR COMMENT
# /= 1.0 08/24/2017 Jake Bentz Created script
# /=
# /=======================================================================#
#
$servername = Read-Host "Hostname(s)"
#
get-vmhost $servername|
%{Get-View $_.ID} |
%{$esxname = $_.Name; Get-View $_.ConfigManager.NetworkSystem} |
%{ foreach($physnic in $_.NetworkInfo.Pnic){
$pnicInfo = $_.QueryNetworkHint($physnic.Device)
foreach($hint in $pnicInfo){
Write-Host $esxname $physnic.Device
if( $hint.ConnectedSwitchPort ) {
$hint.ConnectedSwitchPort
}
else {
Write-Host "No CDP information available."; Write-Host
}
}
}
}