Automation

 View Only
  • 1.  How do I retrieve a list of LACP LAG Uplinks from my Environment?

    Posted Sep 21, 2017 07:04 PM

    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!



  • 2.  RE: How do I retrieve a list of LACP LAG Uplinks from my Environment?
    Best Answer

    Posted Sep 24, 2017 03:12 PM

    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



  • 3.  RE: How do I retrieve a list of LACP LAG Uplinks from my Environment?

    Posted Sep 27, 2017 11:54 AM

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



  • 4.  RE: How do I retrieve a list of LACP LAG Uplinks from my Environment?

    Posted Sep 27, 2017 12:11 PM

    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 



  • 5.  RE: How do I retrieve a list of LACP LAG Uplinks from my Environment?

    Posted Sep 28, 2017 01:06 PM

    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!