Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Get-VMHost did twice #31

Closed
OlivierFaucon opened this issue Jan 9, 2018 · 3 comments
Closed

Get-VMHost did twice #31

OlivierFaucon opened this issue Jan 9, 2018 · 3 comments

Comments

@OlivierFaucon
Copy link

OlivierFaucon commented Jan 9, 2018

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,

@arielsanchezmora
Copy link
Owner

I like this idea! @edmsanchez take a look :)

@edmsanchez
Copy link
Contributor

Hi Oliver,

thanks for the feedback, this has been fixed on v2.4.1

@arielsanchezmora
Copy link
Owner

Fixed, we acknowledged you on the change log, thank you :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants