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.
$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
}
On a calculated property the Expression (E) expects a code block.
Also, the latest vCenter connection is automatically available in $global:defaultviserver.
$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
On a calculated property the Expression (E) expects a code block.
Also, the latest vCenter connection is automatically available in $global:defaultviserver.
$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
Thanks so much for your help! I really appreciate it.
I did a little clean up and here is the end result:
$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