VMware Cloud Community
RobMokkink
Expert
Expert
Jump to solution

get amount of uplinks on distributed switch

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.

Reply
0 Kudos
1 Solution

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

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

View solution in original post

Reply
0 Kudos
5 Replies
firestartah
Virtuoso
Virtuoso
Jump to solution

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

If you found this or other information useful, please consider awarding points for "Correct" or "Helpful". Gregg http://thesaffageek.co.uk
Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

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

Reply
0 Kudos
RobMokkink
Expert
Expert
Jump to solution

Hi Luc,

That was exactly what i was looking for. I missed that part on your website.

Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

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

Reply
0 Kudos
johndavidd
Enthusiast
Enthusiast
Jump to solution

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.

Reply
0 Kudos