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
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
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 :
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
How do you get the output to a file? The following does not work.
| Out-File c:\out.txt
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