Original Message:
Sent: Jun 21, 2024 05:54 AM
From: LucD
Subject: Need active & standby uplink details of standard & distributed switches/portgroups
Since I don't have that older vSphere version running anymore, I can't verify your claim that "... dvSwitch do not have active & standby ports" I'm afraid.
But I don't think that is correct.
You can check via the Web client to verify that there are Teaming options on a VDS and its Portgroups.
The reasons that no Active or Standby ports are shown, could be twofold.
- No Teaming was defined
- The Teaming is defined on the VDS and not on the portgroup
------------------------------
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Original Message:
Sent: Jun 20, 2024 08:20 PM
From: JDMils_Interact
Subject: Need active & standby uplink details of standard & distributed switches/portgroups
I just get this:
ActiveStandby
And I think this is correct because uplinks in the dvSwitch do not have active & standby ports, at least not in vSphere 7.0u3p. They are just representations for the physical connections between the host and the upstream switch and are not teamed. My belief is that the individual port groups are the ones which can be "pinned" to uplinks and this seems to be the case when viewing the properties of the UPLINKS and the port groups.
The Teaming and failover of a port group is represented by:
dvUplink1, dvUplink2, dvUplink3 & dvUplink4
The actual uplink is based on the host as to which vmnic is being used as the uplink for that dvSwitch. This is why I suggested we change the way we look at this and use this format instead:
Switch01 (standard & dv)Host01vLAN01 Name & IDwhich uplink the vLAN has active, standby and unusedvLAN02 Name & IDwhich uplink the vLAN has active, standby and unusedHost02vLAN01 Name & IDwhich uplink the vLAN has active, standby and unusedvLAN02 Name & IDwhich uplink the vLAN has active, standby and unusedSwitch02 (standard & dv)....
My eventual goal is to have a CSV file in this format:
Switch Name, Host Name, vLAN Name, vLAN ID, Active uplink (vmnic#), Standby uplink (vmnic#), Unused uplink (vmnic#)
Original Message:
Sent: Jun 20, 2024 06:27 AM
From: LucD
Subject: Need active & standby uplink details of standard & distributed switches/portgroups
That looks like what I expected.
But it should only show those last 4 ports, provided the ProxyHost corresponds with the ESXi node.
Can you check what is listed as Active and Standby for that VDS?
$pg = Get-VDSwitch -Name 'dvSwitch-MySwitch' | Get-VDPortgroup -Name 'dvSwitch-My-DVUplinks-47'Write-Host 'Active'$pg.extensionData.Config.DefaultPortConfig.UplinkTeamingPolicy.UplinkPortOrder.ActiveUplinkPortWrite-Host 'Standby'$pg.extensionData.Config.DefaultPortConfig.UplinkTeamingPolicy.UplinkPortOrder.StandbyUplinkPort
------------------------------
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Original Message:
Sent: Jun 20, 2024 05:53 AM
From: JDMils_Interact
Subject: Need active & standby uplink details of standard & distributed switches/portgroups
The vDS has multiple hosts attached to it. Output of the Get-DVPort shows the following (removed confidential data) result:
Key Name ConnectedEntity Portgroup IsLinkUp MacAddress Vlan Switch--- ---- --------------- --------- -------- ---------- ---- ------28 vmk3 Site03_vMotion_103 TRUE 00:50:56:6c:e1:01 dvSwitch-MySwitch29 vmk1 Site03_vMotion_103 TRUE 00:50:56:65:11:e5 dvSwitch-MySwitch30 vmk1 Site03_vMotion_103 TRUE 00:50:56:65:f7:26 dvSwitch-MySwitch31 Site03_vMotion_103 dvSwitch-MySwitch32 Site03_vMotion_103 dvSwitch-MySwitch33 Site03_vMotion_103 dvSwitch-MySwitch34 Site03_vMotion_103 dvSwitch-MySwitch35 Site03_vMotion_103 dvSwitch-MySwitch36 Site03_vMotion_103 dvSwitch-MySwitch37 Site03_vMotion_103 dvSwitch-MySwitch38 Site03_vMotion_103 dvSwitch-MySwitch39 Site03_vMotion_103 dvSwitch-MySwitch40 Site03_vMotion_103 dvSwitch-MySwitch142 vmk3 Site03_vMotion_103 TRUE 00:50:56:67:b6:cc dvSwitch-MySwitch404 Network adapter 1 Site03_Mgmt_100 TRUE 00:50:56:c0:11:21 dvSwitch-MySwitch405 Network adapter 1 Site03_Mgmt_100 TRUE 00:50:56:c0:bf:c5 dvSwitch-MySwitch406 Site03_Mgmt_100 dvSwitch-MySwitch407 Network adapter 1 Site03_Mgmt_100 TRUE 00:50:56:c0:c5:b1 dvSwitch-MySwitch408 Network adapter 1 Site03_Mgmt_100 TRUE 00:50:56:c0:cb:54 dvSwitch-MySwitch409 Site03_Mgmt_100 dvSwitch-MySwitch410 Site03_Mgmt_100 dvSwitch-MySwitch411 Site03_Mgmt_100 dvSwitch-MySwitch412 Site03_Mgmt_100 dvSwitch-MySwitch413 Site03_Mgmt_100 dvSwitch-MySwitch414 Site03_Mgmt_100 dvSwitch-MySwitch415 Site03_Mgmt_100 dvSwitch-MySwitch416 Site03_Mgmt_100 dvSwitch-MySwitch417 Site03_Mgmt_100 dvSwitch-MySwitch418 Site03_Mgmt_100 dvSwitch-MySwitch419 Site03_Mgmt_100 dvSwitch-MySwitch420 Site03_Mgmt_100 dvSwitch-MySwitch421 Site03_Mgmt_100 dvSwitch-MySwitch422 Site03_Mgmt_100 dvSwitch-MySwitch423 Site03_Mgmt_100 dvSwitch-MySwitch424 Site03_Mgmt_100 dvSwitch-MySwitch425 Site03_Mgmt_100 dvSwitch-MySwitch426 Site03_Mgmt_100 dvSwitch-MySwitch1574 dvUplink1 vmnic1 dvSwitch-Site03-DVUp... TRUE 00:00:00:00:00:00 dvSwitch-MySwitch1575 dvUplink2 vmnic6 dvSwitch-Site03-DVUp... TRUE 00:00:00:00:00:00 dvSwitch-MySwitch1576 dvUplink3 dvSwitch-Site03-DVUp... dvSwitch-MySwitch1577 dvUplink4 dvSwitch-Site03-DVUp... dvSwitch-MySwitch
Original Message:
Sent: Jun 20, 2024 05:32 AM
From: LucD
Subject: Need active & standby uplink details of standard & distributed switches/portgroups
There was an error in the
$esxObj.VMHost
line for a VDS. I corrected the code above.
Is that a VDS with only one ESXi node connected?
Can you show what Get-VDPort returns for that VDS?
Are you sure the 2nd condition (after the -and) is taken correctly?
It shouldn't be showing VMKernel or VM Network Adapters in the output.
------------------------------
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Original Message:
Sent: Jun 20, 2024 05:05 AM
From: JDMils_Interact
Subject: Need active & standby uplink details of standard & distributed switches/portgroups
The output looks like this:
VMHost : MyHost15.MyDomain.ComSwitch : dvSwitch-MySwitchPortgroup : dvSwitch-My-DVUplinks-47ActivepNIC : vmk5|vmk3|vmk6|Network adapter 1|Network adapter 1|Network adapter 1StandbypNIC : vmk5|vmk3|vmk6|Network adapter 1|Network adapter 1|Network adapter 1
Not sure how you can have the same connections as active AND standby?
What I'd like to see is this:
Switch01 (standard & dv)
Host01
vLAN01 Name & ID
which uplink the vLAN has active, standby and unused
vLAN02 Name & ID
which uplink the vLAN has active, standby and unused
Host02
vLAN01 Name & ID
which uplink the vLAN has active, standby and unused
vLAN02 Name & ID
which uplink the vLAN has active, standby and unused
Switch02 (standard & dv)
....
Original Message:
Sent: Jun 20, 2024 03:16 AM
From: LucD
Subject: Need active & standby uplink details of standard & distributed switches/portgroups
Not sure what you mean, but the output is per ESXi node, and each ESXi node has the same numbering for vNICs (vmnic01, vmnic02, ...)
------------------------------
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Original Message:
Sent: Jun 20, 2024 01:42 AM
From: JDMils_Interact
Subject: Need active & standby uplink details of standard & distributed switches/portgroups
I don't understand the output of your script- there's a lot pf duplication of results?
Original Message:
Sent: Jun 17, 2024 08:32 AM
From: LucD
Subject: Need active & standby uplink details of standard & distributed switches/portgroups
Is this reporting everything you want to see?
Get-VirtualSwitch -PipelineVariable switch |Get-VirtualPortGroup -PipelineVariable pg |ForEach-Object -Process { $obj = New-Object -TypeName PSObject -Property ([ordered]@{ VMHost = '' Switch = $switch.Name Portgroup = $pg.Name ActivepNIC = '' StandbypNIC = '' }) if ($pg -is [VMware.VimAutomation.ViCore.Impl.V1.Host.Networking.VirtualPortGroupImpl]) { $obj.VMHost = (Get-View $pg.VMHostId).Name $obj.ActivepNIC = $pg.ExtensionData.Spec.Policy.NicTeaming.NicOrder.ActiveNic -join '|' $obj.StandbypNIC = $pg.ExtensionData.Spec.Policy.NicTeaming.NicOrder.StandbyNic -join '|' $obj } elseif ($pg -is [VMware.VimAutomation.ViCore.Impl.V1.Host.Networking.DistributedPortGroupImpl]) { if ($pg.ExtensionData.Host) { $ports = Get-VDPort -VDSwitch $switch.Name -ActiveOnly Get-View -Id $pg.ExtensionData.Host -PipelineVariable esx | ForEach-Object -Process { $esxObj = $obj.PSObject.Copy() $esxObj.VMHost = ($switch | Get-VMHost).Name -join '|' $esxObj.ActivepNIC = ($ports | Where-Object { $_.ProxyHost.Name -eq $esx.Name -and $_.Name -in $pg.extensionData.Config.DefaultPortConfig.UplinkTeamingPolicy.UplinkPortOrder.ActiveUplinkPort }).ConnectedEntity -join '|' $esxObj.StandbypNIC = ($ports | Where-Object { $_.ProxyHost.Name -eq $esx.Name -and $_.Name -in $pg.extensionData.Config.DefaultPortConfig.UplinkTeamingPolicy.UplinkPortOrder.StandbyUplinkPort }).ConnectedEntity -join '|' $esxObj } } }}
------------------------------
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Original Message:
Sent: Jun 17, 2024 03:30 AM
From: JDMils_Interact
Subject: Need active & standby uplink details of standard & distributed switches/portgroups
That was to get the uplink details for each host. Code is:
Write-Host "Script Starting" -ForegroundColor Green$report = @()foreach($sw in (Get-VirtualSwitch -Distributed)){ $uuid = $sw.ExtensionData.Summary.Uuid $sw.ExtensionData.Config.Host | %{ $esx = Get-View $_.Config.Host $netSys = Get-View $esx.ConfigManager.NetworkSystem $netSys.NetworkConfig.ProxySwitch | where {$_.Uuid -eq $uuid} | %{ $_.Spec.Backing.PnicSpec | %{ $row = "" | Select Host,dvSwitch,PNic $row.Host = $esx.Name $row.dvSwitch = $sw.Name $row.PNic = $_.PnicDevice $report += $row } } }}$report Write-Host "Script Ended" -ForegroundColor Green
The output is this:
Host dvSwitch PNic---- -------- ----MyHost01 dvSwitch-01 vmnic6MyHost01 dvSwitch-01 vmnic8
I'm now expanding to getting the active & standby uplinks of Standard switches AND dvSwitches via their port groups thus the different code.
Original Message:
Sent: Jun 17, 2024 03:08 AM
From: LucD
Subject: Need active & standby uplink details of standard & distributed switches/portgroups
Didn't you ask a similar question 2 years ago in Export PortGroup uplink details
It looks like the code I provided then was not migrated along with the VMTN migration
------------------------------
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Original Message:
Sent: Jun 17, 2024 02:25 AM
From: JDMils_Interact
Subject: Need active & standby uplink details of standard & distributed switches/portgroups
I'm using this code to get the Standard & Distributed switch active & standby uplinks, however I only get the active/standby uplink names for the Standard switches and not the dvSwitches:
Standard switch results:
"ESX","vSwitch","vSwitch Active NIC","vSwitch Standby NIC","vSwitch Unused NIC","Portgroup","PortGroup VLAN","Device","IP","PortGroup Active NIC","PortGroup StandBy NIC","PortGroup Unused NIC""MyHost01","vSwitch0","vmnic0","vmnic6",,"Management Network","100","vmk0","172.2.12.3","vmnic0,vmnic6","",""
dvSwitch results:
"ESX","vSwitch","vSwitch Active NIC","vSwitch Standby NIC","vSwitch Unused NIC","Portgroup","PortGroup VLAN","Device","IP","PortGroup Active NIC","PortGroup StandBy NIC","PortGroup Unused NIC""MyHost01","dvSwitch-MGT-01",,,,"mgmt_100",,"","","","",""
I have the following setup:
vCenter Name: VC01 (Build 22837322)
Host Name: MyHost01
Standard Switch set to vmnic0=Active, vmnic6=Standby (vLAN100 thus using the same uplinks)
dvSwitch port group 100 shows dvUplink2=Active, dvUplink1=Standby.
Why does the code not show the vLAN uplink active & standby values for each portgroup in the dvSwitch?
Code:
Original code form here:
http://www.underthefleece.co.uk/2015/06/powercli-generating-network.html