Skip to content

Commit 63d2677

Browse files
committed
v1.3.1 release
- Added VMHost network adapter LLDP reporting
1 parent b0938d8 commit 63d2677

File tree

5 files changed

+152
-70
lines changed

5 files changed

+152
-70
lines changed

AsBuiltReport.VMware.vSphere.psd1

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
RootModule = 'AsBuiltReport.VMware.vSphere.psm1'
1313

1414
# Version number of this module.
15-
ModuleVersion = '1.3.0'
15+
ModuleVersion = '1.3.1'
1616

1717
# Supported PSEditions
1818
# CompatiblePSEditions = 'Desktop'
@@ -52,6 +52,10 @@
5252
@{
5353
ModuleName = 'AsBuiltReport.Core';
5454
ModuleVersion = '1.1.0'
55+
},
56+
@{
57+
ModuleName = 'VMware.PowerCLI';
58+
ModuleVersion = '12.3.0'
5559
}
5660
)
5761

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
# :arrows_counterclockwise: VMware vSphere As Built Report Changelog
22

3+
## [[1.3.1](https://github.com/AsBuiltReport/AsBuiltReport.VMware.vSphere/releases/tag/v1.3.1)] - 2021-09-03
4+
5+
### Added
6+
- VMHost network adapter LLDP reporting
7+
38
## [[1.3.0](https://github.com/AsBuiltReport/AsBuiltReport.VMware.vSphere/releases/tag/v1.3.0)] - 2021-08-29
49
### Fixed
510
- Incorrect section reporting with certain InfoLevels

Src/Private/Get-VMHostNetworkAdapterCDP.ps1

Lines changed: 0 additions & 67 deletions
This file was deleted.
Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
function Get-VMHostNetworkAdapterDP {
2+
<#
3+
.SYNOPSIS
4+
Function to retrieve the Network Adapter CDP or LLDP info of a vSphere host.
5+
.DESCRIPTION
6+
Function to retrieve the Network Adapter CDP or LLDP info of a vSphere host.
7+
.PARAMETER VMHost
8+
A vSphere ESXi Host object
9+
.INPUTS
10+
System.Management.Automation.PSObject.
11+
.OUTPUTS
12+
System.Management.Automation.PSObject.
13+
.EXAMPLE
14+
Get-VMHostNetworkAdapterDP -VMHost ESXi01,ESXi02
15+
.EXAMPLE
16+
Get-VMHost ESXi01,ESXi02 | Get-VMHostNetworkAdapterDP
17+
#>
18+
[CmdletBinding()][OutputType('System.Management.Automation.PSObject')]
19+
20+
Param
21+
(
22+
[parameter(Mandatory = $true, ValueFromPipeline = $true)]
23+
[ValidateNotNullOrEmpty()]
24+
[PSObject[]]$VMHost
25+
)
26+
27+
begin {
28+
$ObjOutput = @()
29+
}
30+
31+
process {
32+
try {
33+
foreach ($ObjVMHost in $VMHost) {
34+
$ConfigManagerView = Get-View $ObjVMHost.ExtensionData.ConfigManager.NetworkSystem
35+
$pNics = $ConfigManagerView.NetworkInfo.Pnic
36+
foreach ($pNic in $pNics) {
37+
$PhysicalNicHintInfo = $ConfigManagerView.QueryNetworkHint($pNic.Device)
38+
if ($PhysicalNicHintInfo.ConnectedSwitchPort) {
39+
$Object = [PSCustomObject]@{
40+
'Host' = $ObjVMHost.Name
41+
'Device' = $pNic.Device
42+
'Status' = if ($PhysicalNicHintInfo.ConnectedSwitchPort) {
43+
'Connected'
44+
} else {
45+
'Disconnected'
46+
}
47+
'SwitchId' = $PhysicalNicHintInfo.ConnectedSwitchPort.DevId
48+
'Address' = $PhysicalNicHintInfo.ConnectedSwitchPort.Address
49+
'VLAN' = $PhysicalNicHintInfo.ConnectedSwitchPort.Vlan
50+
'MTU' = $PhysicalNicHintInfo.ConnectedSwitchPort.Mtu
51+
'SystemName' = $PhysicalNicHintInfo.ConnectedSwitchPort.SystemName
52+
'Location' = $PhysicalNicHintInfo.ConnectedSwitchPort.Location
53+
'HardwarePlatform' = $PhysicalNicHintInfo.ConnectedSwitchPort.HardwarePlatform
54+
'SoftwareVersion' = $PhysicalNicHintInfo.ConnectedSwitchPort.SoftwareVersion
55+
'ManagementAddress' = $PhysicalNicHintInfo.ConnectedSwitchPort.MgmtAddr
56+
'PortId' = $PhysicalNicHintInfo.ConnectedSwitchPort.PortId
57+
}
58+
$ObjOutput += $Object
59+
}
60+
if ($PhysicalNicHintInfo.LldpInfo) {
61+
$Object = [PSCustomObject]@{
62+
'Host' = $ObjVMHost.Name
63+
'Device' = $pNic.Device
64+
'ChassisId' = $PhysicalNicHintInfo.LldpInfo.ChassisId
65+
'PortId' = $PhysicalNicHintInfo.LldpInfo.PortId
66+
'TimeToLive' = $PhysicalNicHintInfo.LldpInfo.TimeToLive
67+
'TimeOut' = ($PhysicalNicHintInfo.LldpInfo.Parameter | Where-Object {$_.key -eq "TimeOut"}).Value
68+
'Samples' = ($PhysicalNicHintInfo.LldpInfo.Parameter | Where-Object {$_.key -eq "Samples"}).Value
69+
'ManagementAddress' = ($PhysicalNicHintInfo.LldpInfo.Parameter | Where-Object {$_.key -eq "Management Address"}).Value
70+
'PortDescription' = ($PhysicalNicHintInfo.LldpInfo.Parameter | Where-Object {$_.key -eq "Port Description"}).Value
71+
'SystemDescription' = ($PhysicalNicHintInfo.LldpInfo.Parameter | Where-Object {$_.key -eq "System Description"}).Value
72+
'SystemName' = ($PhysicalNicHintInfo.LldpInfo.Parameter | Where-Object {$_.key -eq "System Name"}).Value
73+
}
74+
$ObjOutput += $Object
75+
}
76+
}
77+
}
78+
} catch [Exception] {
79+
throw 'Unable to retrieve CDP/LLDP info'
80+
}
81+
}
82+
end {
83+
Write-Output $ObjOutput
84+
}
85+
}

Src/Public/Invoke-AsBuiltReport.VMware.vSphere.ps1

Lines changed: 57 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ function Invoke-AsBuiltReport.VMware.vSphere {
55
.DESCRIPTION
66
Documents the configuration of VMware vSphere infrastucture in Word/HTML/Text formats using PScribo.
77
.NOTES
8-
Version: 1.3.0
8+
Version: 1.3.1
99
Author: Tim Carman
1010
Twitter: @tpcarman
1111
Github: tpcarman
@@ -2422,7 +2422,7 @@ function Invoke-AsBuiltReport.VMware.vSphere {
24222422
#endregion ESXi Host Physical Adapters
24232423

24242424
#region ESXi Host Cisco Discovery Protocol
2425-
$VMHostNetworkAdapterCDP = $VMHost | Get-VMHostNetworkAdapterCDP | Where-Object { $_.Status -eq 'Connected' } | Sort-Object Device
2425+
$VMHostNetworkAdapterCDP = $VMHost | Get-VMHostNetworkAdapterDP | Where-Object { $_.Status -eq 'Connected' } | Sort-Object Device
24262426
if ($VMHostNetworkAdapterCDP) {
24272427
Section -Style Heading5 'Cisco Discovery Protocol' {
24282428
Paragraph "The following section details the CDP information for $VMHost."
@@ -2477,6 +2477,61 @@ function Invoke-AsBuiltReport.VMware.vSphere {
24772477
}
24782478
#endregion ESXi Host Cisco Discovery Protocol
24792479

2480+
#region ESXi Host Link Layer Discovery Protocol
2481+
$VMHostNetworkAdapterLLDP = $VMHost | Get-VMHostNetworkAdapterDP | Where-Object { $null -ne $_.ChassisId } | Sort-Object Device
2482+
if ($VMHostNetworkAdapterLLDP) {
2483+
Section -Style Heading5 'Link Layer Discovery Protocol' {
2484+
Paragraph "The following section details the LLDP information for $VMHost."
2485+
if ($InfoLevel.VMHost -ge 4) {
2486+
foreach ($VMHostNetworkAdapter in $VMHostNetworkAdapterLLDP) {
2487+
Section -Style Heading5 "$($VMHostNetworkAdapter.Device)" {
2488+
$VMHostLLDP = [PSCustomObject]@{
2489+
'Chassis ID' = $VMHostNetworkAdapter.ChassisId
2490+
'Port ID' = $VMHostNetworkAdapter.PortId
2491+
'Time to live' = $VMHostNetworkAdapter.TimeToLive
2492+
'TimeOut' = $VMHostNetworkAdapter.TimeOut
2493+
'Samples' = $VMHostNetworkAdapter.Samples
2494+
'Management Address' = $VMHostNetworkAdapter.ManagementAddress
2495+
'Port Description' = $VMHostNetworkAdapter.PortDescription
2496+
'System Description' = $VMHostNetworkAdapter.SystemDescription
2497+
'System Name' = $VMHostNetworkAdapter.SystemName
2498+
}
2499+
$TableParams = @{
2500+
Name = "Network Adapter $($VMHostNetworkAdapter.Device) LLDP Information - $VMHost"
2501+
List = $true
2502+
ColumnWidths = 50, 50
2503+
}
2504+
if ($Report.ShowTableCaptions) {
2505+
$TableParams['Caption'] = "- $($TableParams.Name)"
2506+
}
2507+
$VMHostLLDP | Table @TableParams
2508+
}
2509+
}
2510+
} else {
2511+
BlankLine
2512+
$VMHostLLDP = foreach ($VMHostNetworkAdapter in $VMHostNetworkAdapterLLDP) {
2513+
[PSCustomObject]@{
2514+
'Adapter' = $VMHostNetworkAdapter.Device
2515+
'Chassis ID' = $VMHostNetworkAdapter.ChassisId
2516+
'Port ID' = $VMHostNetworkAdapter.PortId
2517+
'Management Address' = $VMHostNetworkAdapter.ManagementAddress
2518+
'Port Description' = $VMHostNetworkAdapter.PortDescription
2519+
'System Name' = $VMHostNetworkAdapter.SystemName
2520+
}
2521+
}
2522+
$TableParams = @{
2523+
Name = "Network Adapter LLDP Information - $VMHost"
2524+
ColumnWidths = 11, 19, 16, 19, 18, 17
2525+
}
2526+
if ($Report.ShowTableCaptions) {
2527+
$TableParams['Caption'] = "- $($TableParams.Name)"
2528+
}
2529+
$VMHostLLDP | Table @TableParams
2530+
}
2531+
}
2532+
}
2533+
#endregion ESXi Host Link Layer Discovery Protocol
2534+
24802535
#region ESXi Host VMkernel Adapaters
24812536
Section -Style Heading5 'VMkernel Adapters' {
24822537
Paragraph "The following section details the VMkernel adapter configuration for $VMHost"

0 commit comments

Comments
 (0)