I am looking for a way to determine the amount of uplinks connected to a distributed switch.
It this possible through a cmdlet or SDK. I have looked bt can't find it.
The following function just gives the names of the uplinks of a specific dvSwitch.
I had this function in my toolbox but didn't consider it worth a separate post.
You use it together with my Get-dvSwitch function I posted in dvSwitch scripting – Part 2 – dvPortgroup.
function Get-dvSwUplinks{ param([parameter(Mandatory = $true, ValueFromPipeline = $true)] [http://VMware.Vim.VmwareDistributedVirtualSwitch|http://VMware.Vim.VmwareDistributedVirtualSwitch]$dvSw) Process{ $dvSw.Config.UplinkPortPolicy.UplinkPortName | %{ New-Object PSObject -Property @{ UplinkName = $_ } } } }
You use it like this
Get-dvSwitch "DC1" "dvSw1" | Get-dvSwUplinks
And it will return this
UplinkName ---------- dvUplink1 dvUplink2 dvUplink3 dvUplink4
If you only need the amount of Uplinks you can do
(Get-dvSwitch "DC1" "dvSw1" | Get-dvSwUplinks).Count
I was thinking of expanding this function with other properties like Port ID, Connectee, Portgroup...
In short what you see in the vSphere client.
Is there anything specific you want to see returned by the function ?
____________
Blog: LucD notes
Twitter: lucd22
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
You can see it via the console but guessing by you asking the powershell cmdlet you don;t have or don;t want to do it this way so
Get
-dvSwUplink
should work.
If you found this or other information useful, please consider awarding points for "Correct" or "Helpful".
Gregg Robertson, VCP3,4 , MCSE, MCSA, MCTS, MCITP
The following function just gives the names of the uplinks of a specific dvSwitch.
I had this function in my toolbox but didn't consider it worth a separate post.
You use it together with my Get-dvSwitch function I posted in dvSwitch scripting – Part 2 – dvPortgroup.
function Get-dvSwUplinks{ param([parameter(Mandatory = $true, ValueFromPipeline = $true)] [http://VMware.Vim.VmwareDistributedVirtualSwitch|http://VMware.Vim.VmwareDistributedVirtualSwitch]$dvSw) Process{ $dvSw.Config.UplinkPortPolicy.UplinkPortName | %{ New-Object PSObject -Property @{ UplinkName = $_ } } } }
You use it like this
Get-dvSwitch "DC1" "dvSw1" | Get-dvSwUplinks
And it will return this
UplinkName ---------- dvUplink1 dvUplink2 dvUplink3 dvUplink4
If you only need the amount of Uplinks you can do
(Get-dvSwitch "DC1" "dvSw1" | Get-dvSwUplinks).Count
I was thinking of expanding this function with other properties like Port ID, Connectee, Portgroup...
In short what you see in the vSphere client.
Is there anything specific you want to see returned by the function ?
____________
Blog: LucD notes
Twitter: lucd22
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Hi Luc,
That was exactly what i was looking for. I missed that part on your website.
It's not (yet) on my website.
I was thinking of other uplink properties to return.
I'll think I go for all the properties that are visible in the vSphere client.
____________
Blog: LucD notes
Twitter: lucd22
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
LucD .... Did you ever finish this function and add all the properties in? I'm looking for it to return the port ID and connectee you see in the vSphere Client.