Created
December 18, 2021 20:31
-
-
Save kapb14/73a48cf751517c3602e096e40a7a3877 to your computer and use it in GitHub Desktop.
Get information about vSphere host physical ports CDP
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$cdpVar = ForEach ($dstHost in $(Get-VMHost)) | |
{ | |
$NetSystem = Get-View $dstHost.ExtensionData.ConfigManager.NetworkSystem | |
foreach ($Pnic in $dstHost.ExtensionData.Config.Network.Pnic) | |
{ | |
if ($Pnic.Device -notlike "vusb*") | |
{ | |
$PnicInfo = $NetSystem.QueryNetworkHint($Pnic.Device) | |
$cdp = $PnicInfo.ConnectedSwitchPort | |
[pscustomobject]@{ | |
server = $dstHost.Name | |
serverPort = $Pnic.Device | |
cdpDevice = $cdp.DevId | |
cdpDevicePort = $cdp.PortId | |
} | |
} | |
} | |
} | |
# $cdpVar | |
$cdpVar | Export-Excel -Path C:\temp\vs5vmvlans.xlsx ` | |
-Title "какой сервер каким портом в какую циску воткнут" ` | |
-TableName "CiscoPorts" ` | |
-WorksheetName "CiscoPorts" ` | |
-AutoSize ` | |
-Show ` | |
-Append |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment