VMware Cloud Community
BenLiebowitz
Expert
Expert
Jump to solution

How do I retrieve a list of LACP LAG Uplinks from my Environment?

We have an environment where each vDS uses LACP and has a LAG uplink.  I'd like a way to list the different LAG names via PowerCLI.  This needs to be across multiple vDS switches. 

I know I can point ESXCLI to a specific host and get the information from: $esxcli.network.vswitch.dvs.vmware.lacp.config.get(), and I found if I do a Get-VDSwitch | Get-VDPortgroup | where {$_.Name -match "2"} | Get-VDUplinkTeamingPolicy, it's listed under "ActiveUplinkPort".  But I'd like to run a script that lists...

ProdLAG

StgLAG

DEVLAG

etc...

Can someone help? 

LUC?!  I'm sending up the LUC SIGNAL!

Luc_Signal.jpg

Ben Liebowitz, VCP vExpert 2015, 2016, & 2017 If you found my post helpful, please mark it as helpful or answered to award points.
Tags (2)
0 Kudos
1 Solution

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

Not sure I got the question 100%, but do you mean something like this?

$lagInfo = foreach($vds in Get-VDSwitch){

    $vds | Get-VMHost | %{

        $esxcli = Get-EsxCli -VMHost $_

        $esxcli.network.vswitch.dvs.vmware.lacp.config.get() |

            Select DVSName,LAGName,LAGID

    }

}

$lagInfo | Sort-Object -Property LAGName -Unique


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

View solution in original post

4 Replies
LucD
Leadership
Leadership
Jump to solution

Not sure I got the question 100%, but do you mean something like this?

$lagInfo = foreach($vds in Get-VDSwitch){

    $vds | Get-VMHost | %{

        $esxcli = Get-EsxCli -VMHost $_

        $esxcli.network.vswitch.dvs.vmware.lacp.config.get() |

            Select DVSName,LAGName,LAGID

    }

}

$lagInfo | Sort-Object -Property LAGName -Unique


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

BenLiebowitz
Expert
Expert
Jump to solution

Is there any way to also include which vmnics are a part of each lag also?  Smiley Happy

Ben Liebowitz, VCP vExpert 2015, 2016, & 2017 If you found my post helpful, please mark it as helpful or answered to award points.
0 Kudos
LucD
Leadership
Leadership
Jump to solution

Something like this?

$lagInfo = foreach($vds in Get-VDSwitch){

    $vds | Get-VMHost | %{

        $esxcli = Get-EsxCli -VMHost $_

        $vnic = $esxcli.network.vswitch.dvs.vmware.list() | where{$_.Name -eq $vds.Name} | Select -ExpandProperty Uplinks

        $esxcli.network.vswitch.dvs.vmware.lacp.config.get() |  where{$_.DVSName -eq $vds.Name} |

            Select DVSName,LAGName,LAGID,@{N='vmnic';E={($vnic | Sort-Object) -join '|'}}

    }

}

$lagInfo | Sort-Object -Property LAGName -Unique

Update: note that this does not handle identical lagnames on different switches correctly

You would need to change the last line to

$lagInfo | Sort-Object -Property DVSName,LAGName -Unique 


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

BenLiebowitz
Expert
Expert
Jump to solution

The lag names are all unique so no need for the DVS name, but thanks!  This is exactly what I wanted. 

You're the man!

Ben Liebowitz, VCP vExpert 2015, 2016, & 2017 If you found my post helpful, please mark it as helpful or answered to award points.
0 Kudos