LucD
Leadership
Leadership

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