You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I notice that, except when parameter esxi is chosen, the Get-VMHost is done twice.
Once, creating the $vHostList or the $tempList, and afterwards getting $vmhost.
I would suggest to keep it as it is for parameters datacenter and cluster, and modify the $vHostList for ESXi parameter :
foreach ($invidualHost in $esxi) { # $vHostList += $invidualHost.Trim() | Sort-Object -Property Name $vHostList += $invidualHost.Trim()
} #END foreach
# $vHostList = Get-VMHost -Name $vHostList | Sort-Object -Property Name
#
And change the foreach loop : # foreach ($esxihost in $vHostList) { foreach ($vmhost in $vHostList) {
and replace $esxihost by $vmhost in the $skipCollection and $esxcli2 :
$skipCollection += [pscustomobject]@{ # 'Hostname' = $esxihost 'Hostname' = $vmhost.name # 'Connection State' = $esxihost.ConnectionState 'Connection State' = $vmhost.ConnectionState
} #END [PSCustomObject]
continue
} #END if/else # $esxcli2 = Get-EsxCli -VMHost $esxihost -V2 $esxcli2 = Get-EsxCli -VMHost $vmhost -V2
When managing many vCenters with hundreds of ESXi, this modification gives faster results.
Thanks,
The text was updated successfully, but these errors were encountered:
Hello,
Very nice scripts, many thanks.
I notice that, except when parameter esxi is chosen, the Get-VMHost is done twice.
Once, creating the $vHostList or the $tempList, and afterwards getting $vmhost.
I would suggest to keep it as it is for parameters datacenter and cluster, and modify the $vHostList for ESXi parameter :
foreach ($invidualHost in $esxi) {
# $vHostList += $invidualHost.Trim() | Sort-Object -Property Name
$vHostList += $invidualHost.Trim()
} #END foreach
#
$vHostList = Get-VMHost -Name $vHostList | Sort-Object -Property Name
#
And change the foreach loop :
# foreach ($esxihost in $vHostList) {
foreach ($vmhost in $vHostList) {
and replace $esxihost by $vmhost in the $skipCollection and $esxcli2 :
$skipCollection += [pscustomobject]@{
# 'Hostname' = $esxihost
'Hostname' = $vmhost.name
# 'Connection State' = $esxihost.ConnectionState
'Connection State' = $vmhost.ConnectionState
} #END [PSCustomObject]
continue
} #END if/else
# $esxcli2 = Get-EsxCli -VMHost $esxihost -V2
$esxcli2 = Get-EsxCli -VMHost $vmhost -V2
When managing many vCenters with hundreds of ESXi, this modification gives faster results.
Thanks,
The text was updated successfully, but these errors were encountered: