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!
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
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
Is there any way to also include which vmnics are a part of each lag also?
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
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!