VMware Cloud Community
blueten
Contributor
Contributor
Jump to solution

Get RSS setting for each vmnicX on each host in multiple vCenters and export to file

I'm attempting to list the RSS setting for each vmnic on each ESXi host from a list of vCenters.

I'm able to list the vCenter, nic and RSS settings but can't list each ESXi host so I can easily review all the vCenters, ESXi Hosts, vmnicX and RSS settings.

Could someone please help me with identifying a way to capture the ESXi host?

Thank you.

#Export CSV file name

$ExportFilePath = "c:\temp\RSSLB_MultipleVCenters.csv"


#Connect to the multiple vCenter servers. Ignore certificate errors

Write-Host "Connecting to vCenters" -ForegroundColor Cyan


$VIServers = Get-Content -Path C:\temp\vcenters.txt

$c = Get-Credential


Foreach ($VIServer in $VIServers){

    $VIServer = Connect-VIServer $VIServer -Credential $c  -warningaction 0

    Write-Host "Connected to $VIServer" -ForegroundColor Cyan


    #List the RSS setting for each host in vCenter

    Get-VMHost | ForEach {

        $VMHost = $_

        $esxcli = Get-EsxCli -V2 -VMHost $VMHost

            ForEach-Object {

                $esxcli.network.nic.queue.loadbalancer.list.Invoke() | Select NIC,RSS,@{N="ESXi Host";E="$VMHost"},@{N="VCenterServer";E={$VIServer}} | FT

                $esxcli.network.nic.queue.loadbalancer.list.Invoke() | Select NIC,RSS,@{N="ESXi Host";E="$VMHost"},@{N="VCenterServer";E={$VIServer}} | Export-Csv -Path $ExportFilePath -Append -NoTypeInformation

                       }

    #Export results to file

    Export-Csv  -Path $ExportFilePath -Append -NoTypeInformation

    # Disconnect from vCenter

    Disconnect-VIServer $VIServer -confirm:$false

    Write-Host "Disconnected from $VIServer " -ForegroundColor Yellow

    }

Write-Host "RSS Info located at $ExportFilePath" -ForegroundColor Magenta

}

0 Kudos
1 Solution

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

On a calculated property the Expression (E) expects a code block.

Also, the latest vCenter connection is automatically available in $global:defaultviserver.

#Export CSV file name

$ExportFilePath = "c:\temp\RSSLB_MultipleVCenters.csv"


#Connect to the multiple vCenter servers. Ignore certificate errors

Write-Host "Connecting to vCenters" -ForegroundColor Cyan


$VIServers = Get-Content -Path C:\temp\vcenters.txt

$c = Get-Credential


Foreach ($VIServer in $VIServers) {

    Connect-VIServer $VIServer -Credential $c  -warningaction 0 | Out-Null

    Write-Host "Connected to $VIServer" -ForegroundColor Cyan


    #List the RSS setting for each host in vCenter

    Get-VMHost | ForEach {

        $VMHost = $_

        $esxcli = Get-EsxCli -V2 -VMHost $VMHost

        ForEach-Object {

            $esxcli.network.nic.queue.loadbalancer.list.Invoke() |

            Select NIC, RSS,

                @{N = "ESXi Host"; E = {$vmHost.Name} },

                @{N = "VCenterServer"; E = { $global:defaultVIServer.Name } } |

            Format-Table


            $esxcli.network.nic.queue.loadbalancer.list.Invoke() |

            Select NIC, RSS,

                @{N = "ESXi Host"; E = {$vmHost.Name} },

                @{N = "VCenterServer"; E = { $global:defaultVIServer.Name } } |

            Export-Csv -Path $ExportFilePath -Append -NoTypeInformation

        }


        #Export results to file

        Export-Csv  -Path $ExportFilePath -Append -NoTypeInformation


        # Disconnect from vCenter

        Disconnect-VIServer $VIServer -confirm:$false

        Write-Host "Disconnected from $VIServer " -ForegroundColor Yellow

    }

    Write-Host "RSS Info located at $ExportFilePath" -ForegroundColor Magenta

}

---------------------------------------------------------------------------------------------------------

Was it helpful? Let us know by completing this short survey here.


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

View solution in original post

0 Kudos
2 Replies
LucD
Leadership
Leadership
Jump to solution

On a calculated property the Expression (E) expects a code block.

Also, the latest vCenter connection is automatically available in $global:defaultviserver.

#Export CSV file name

$ExportFilePath = "c:\temp\RSSLB_MultipleVCenters.csv"


#Connect to the multiple vCenter servers. Ignore certificate errors

Write-Host "Connecting to vCenters" -ForegroundColor Cyan


$VIServers = Get-Content -Path C:\temp\vcenters.txt

$c = Get-Credential


Foreach ($VIServer in $VIServers) {

    Connect-VIServer $VIServer -Credential $c  -warningaction 0 | Out-Null

    Write-Host "Connected to $VIServer" -ForegroundColor Cyan


    #List the RSS setting for each host in vCenter

    Get-VMHost | ForEach {

        $VMHost = $_

        $esxcli = Get-EsxCli -V2 -VMHost $VMHost

        ForEach-Object {

            $esxcli.network.nic.queue.loadbalancer.list.Invoke() |

            Select NIC, RSS,

                @{N = "ESXi Host"; E = {$vmHost.Name} },

                @{N = "VCenterServer"; E = { $global:defaultVIServer.Name } } |

            Format-Table


            $esxcli.network.nic.queue.loadbalancer.list.Invoke() |

            Select NIC, RSS,

                @{N = "ESXi Host"; E = {$vmHost.Name} },

                @{N = "VCenterServer"; E = { $global:defaultVIServer.Name } } |

            Export-Csv -Path $ExportFilePath -Append -NoTypeInformation

        }


        #Export results to file

        Export-Csv  -Path $ExportFilePath -Append -NoTypeInformation


        # Disconnect from vCenter

        Disconnect-VIServer $VIServer -confirm:$false

        Write-Host "Disconnected from $VIServer " -ForegroundColor Yellow

    }

    Write-Host "RSS Info located at $ExportFilePath" -ForegroundColor Magenta

}

---------------------------------------------------------------------------------------------------------

Was it helpful? Let us know by completing this short survey here.


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

0 Kudos
blueten
Contributor
Contributor
Jump to solution

Thanks so much for your help! I really appreciate it. 

I did a little clean up and here is the end result:

#Create variable for exporting results to CSV file

$ExportFilePath = "\\servername\c$\temp\RSSLB_MultipleVCenters.csv"


#Connect to the multiple vCenter servers. Ignore certificate errors

Write-Host "Connecting to vCenters" -ForegroundColor Cyan


$VIServers = Get-Content -Path C:\temp\vcenters.txt

$c = Get-Credential


Foreach ($VIServer in $VIServers) {

    Connect-VIServer $VIServer -Credential $c  -warningaction 0 | Out-Null

    Write-Host "Connected to $VIServer" -ForegroundColor Cyan


    #List the RSS setting for each host in vCenter

    Get-VMHost | ForEach {

        $VMHost = $_

        $esxcli = Get-EsxCli -V2 -VMHost $VMHost

        ForEach-Object {

            $esxcli.network.nic.queue.loadbalancer.list.Invoke() |

            Select NIC, RSS,

                @{N = "ESXi Host"; E = {$vmHost.Name} },

                @{N = "VCenterServer"; E = { $global:defaultVIServer.Name } } |

            Format-Table


           $esxcli.network.nic.queue.loadbalancer.list.Invoke() |

           Select NIC, RSS,

               @{N = "ESXi Host"; E = {$vmHost.Name} },

               @{N = "VCenterServer"; E = { $global:defaultVIServer.Name } } |

           Export-Csv -Path $ExportFilePath -Append -NoTypeInformation

        }


    }

   

}


Write-Host "RSS Info located at $ExportFilePath" -ForegroundColor Magenta

# Disconnect from vCenters

Disconnect-VIServer * -confirm:$false

0 Kudos