VMware Cloud Community
E4F
Contributor
Contributor
Jump to solution

Monitor vSwitch

I am trying to get the name of the ESX host, and the vSwitches, but I can't seem to get the ESX Hostname

Get-VMHost | Get-VirtualSwitch | Get-NicTeamingPolicy

Desired Output:

Name          VirtualSwitch   ActiveNic       StandbyNic      UnusedNic       FailbackEnabled NotifySwitches
---------          -------------   ---------       ----------      ---------       --------------- --------------
HostName   vSwitch0        {xsigo_xnic1}   {xsigo_xnic0}                   True            True
                      vSwitch1        {xsigo_xnic3...                                 True            True

Reply
0 Kudos
1 Solution

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

One way of doing this, is like this

$report = foreach($esx in Get-VMHost){
    foreach($sw in (Get-VirtualSwitch -VMHost $esx -Standard)){
        Get-NicTeamingPolicy -VirtualSwitch $sw | `
       
Select @{N="Hostname";E={$esx.Name}},             @{N="VirtualSwitch";E={$sw.Name}},             @{N="ActiveNic";E={[string]::Join(',',$_.ActiveNic)}},             @{N="StandbyNic";E={[string]::Join(',',$_.StandbyNic)}} | ft -AutoSize
    } }
$report | Out-File "C:\report.txt"


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

View solution in original post

Reply
0 Kudos
4 Replies
E4F
Contributor
Contributor
Jump to solution

Optimal Output would be

PS D:\Scripts> Get-VMHost | Get-VirtualSwitch | Get-NicTeamingPolicy | FL

Hosthame                    :Hostname
VirtualSwitch               : vSwitch0
ActiveNic                     : {xnic1}
StandbyNic                  : {xnic0}

VirtualSwitch                : vSwitch1
ActiveNic                      : {xnic3, xnic2}
StandbyNic                   :

Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

Try something like this

foreach($esx in Get-VMHost){
    foreach($sw in (Get-VirtualSwitch -VMHost $esx -Standard)){
        Get-NicTeamingPolicy -VirtualSwitch $sw | `
        Select @{N="Hostname";E={$esx.Name}},             @{N="VirtualSwitch";E={$sw.Name}},             @{N="ActiveNic";E={[string]::Join(',',$_.ActiveNic)}},             @{N="StandbyNic";E={[string]::Join(',',$_.StandbyNic)}}     } }


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

E4F
Contributor
Contributor
Jump to solution

How do you get the output to a file?  The following does not work.

| Out-File c:\out.txt

Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

One way of doing this, is like this

$report = foreach($esx in Get-VMHost){
    foreach($sw in (Get-VirtualSwitch -VMHost $esx -Standard)){
        Get-NicTeamingPolicy -VirtualSwitch $sw | `
       
Select @{N="Hostname";E={$esx.Name}},             @{N="VirtualSwitch";E={$sw.Name}},             @{N="ActiveNic";E={[string]::Join(',',$_.ActiveNic)}},             @{N="StandbyNic";E={[string]::Join(',',$_.StandbyNic)}} | ft -AutoSize
    } }
$report | Out-File "C:\report.txt"


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

Reply
0 Kudos