VMware Cloud Community
Alexandre2
Contributor
Contributor

Powercli script to get DVS status, VLAN health status, MTU status, Teaming and failover status

Hi,

I've already a powercli script to have the DVS status, but I want to have all status of the network health check.

Someone can help me ?

Thanks in advance.

Reply
0 Kudos
3 Replies
LucD
Leadership
Leadership

The VDS Health check results are not really documented.
I looked at this in the past, and I think I have been able to calculate all of them, except for the VLAN Health Status.

This is what I have so far

Get-VDSwitch -PipelineVariable vds |
ForEach-Object -Process {
    $vds.ExtensionData.Runtime.HostMemberRuntime |
    ForEach-Object -Process {
        $esx = Get-View -Id $_.Host -Property Name,'Runtime.ConnectionState'
        New-Object -TypeName PSObject -Property @{
            VDS = $vds.Name
            HostName = $esx.Name
            State = $esx.Runtime.ConnectionState
            VDSStatus = $_.Status
            Teaming = if($_.HealthCheckResult.TeamingStatus -notmatch 'Mismatch'){'Normal'}else{'Warning'}
            MTU = if($_.HealthCheckResult.Where({$_ -is [VMware.Vim.VMwareDVSMtuHealthCheckResult]}).MtuMisMatch -notcontains $true){'Normal'}else{'Warning'}
            VLAN = '?'
        }
    }
}


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

PcChip
Contributor
Contributor

this is very close to what we need, we just need the VLAN results - were you ever able to find those? 

 

Thanks for posting up what you have!

Reply
0 Kudos
LucD
Leadership
Leadership

The last version I have includes the VLAN,MTU and Teaming health check status.
But use at your own risk!

I'm not 100% sure the script interprets the results correctly in all situations.

Get-VDSwitch -PipelineVariable vds |
ForEach-Object -Process {
    $vds.ExtensionData.Runtime.HostMemberRuntime |
    ForEach-Object -Process {
        $esx = Get-View -Id $_.Host -Property Name, 'Runtime.ConnectionState'
        $obj = New-Object -TypeName PSObject -Property ([ordered]@{
            VDS = $vds.Name
            HostName = $esx.Name
            State = $esx.Runtime.ConnectionState
            VDSStatus = $_.Status
            VLANandMTUHealth = 'Disabled'
            TeamingHealth = 'Disabled'
            Teaming = ''
            MTU = '? unknown'
            VLAN = '? unknown'
        })
        if($vds.ExtensionData.Config.HealthCheckConfig[0].Enable) {
            $obj.VLANandMTUHealth = 'Enabled'
            $obj.VLAN = if ($_.HealthCheckResult.Where({ $_ -is [VMware.Vim.VMwareDVSVlanHealthCheckResult] }).UntrunkedVlan -eq $null) { 'Normal' }else { 'Warning' }
        }
        if ($vds.ExtensionData.Config.HealthCheckConfig[1].Enable) {
            $obj.TeamingHealth = 'Enabled'
            $obj.Teaming = &{
                $teaming = $_.HealthCheckResult.Where({ $_ -is [VMware.Vim.VMwareDVSTeamingHealthCheckResult] })
                if($teaming){
                    if ($teaming.TeamingStatus -match 'Mismatch'){'Warning'}else{'Normal'}
                }
                else{'? unknown'}
            }
            $obj.MTU = &{
                $mtu = $_.HealthCheckResult.Where({ $_ -is [VMware.Vim.VMwareDVSMtuHealthCheckResult] })
                if ($mtu.VlanNotSupportSwitchMtu -ne $null){'Warning'}else{'Normal'}
            }
        }
        $obj
    }
}


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

Reply
0 Kudos