In one vcenter environment, when I run "Get-VMHost" I get the 3 host names returned with names like "HostSystem-host-42". (for the ID)
In another vcenter environment "Get-VMHost" returns the host twice, one with an ID something like "HostSystem-host-44" and "HostSystem-ha-host" (the host name for both is the same).
Why is there a difference?
Should I be concerned?
We have horrible slowness issues in the vcenter, and just looking around.
If you connect multiple times to your vCenter, it is possible to get duplicate entries.
So if your script has a "connect-viserver" and you don't disconnect and run the script again, you already have 2 sessions which results in returning duplicate hosts while using "get-vmhost"
Be sure to use only one connection. I presume you don't see duplicates in the vCenter GUI
?
Welcome to community,
I had experienced something similar but because of different set of actions (not duplicate vCenter connection).
If you have connected to the "single host" or "group of hosts" before or after connecting to vCenter server you can get same result.
In the attach screen shot I've listed VMHosts before connecting to host separately and after that (Duplicate-001 screenshot).
I'm new in using PowerShell and PowerCLI so I tested just as Wh33ly said but I didn't get that result. (Duplicate-002 screenshot).
Side note:
$global:DefaultVIServers | Select Name,Port,User,RefCount | Format-Table -AutoSize
This command would show you your current connections and if you have duplicate connection to any vCenter or host, it's related "RefCount" would be greater than 1.
Kasraeian you're right, while connecting multiple times I don't seem to get the result I had once before (probably I was connected to another host also :S)
By connecting to one or more hosts and vCenter, the hosts I connected to return as duplicate, seems logic now I think about it.
Sorry for the wrong turn...
Wh33ly I'm newbie in using PowerCLI and PowerShell and there might be conditions connecting to multiple vCenter returning duplicates as well but I didn't face them yet so you still might be right ![]()
Kasraeian same for me, I try to reproduce this at work next week. Wasn't possible to recreate this through powercli itself like you mentioned.
Might be caused by a mix of PowerGui and PowerCLI I was playing with, will let you know if I find something
That would be great, I'm looking forward to it.
Moved to a more apporiate forum -
With the Set-PowerCLIConfiguration cmdlet you can control if you want the PowerCLI cmdlets to act on a Single or on Multiple connections.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Not sure why but the get-vmhost not only returned the host name, but also the name with the "High Availablity" dash (or -HA) on the end.
At the time two of the hosts were configured that way, and one was not, so the loop returned 5 names (which can mess up your loop if you know what I mean).
After fixing some problems we had in vCenter, and making sure all the hosts were configured with HA, the loop then returned 3 names again like it should...
???
That looks as if you were connected to the vCenter and the ESXi server(s).
You can check which connection are open with
$defaultVIServers
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Hello
Have u checked the DNS ? Host file ? is there any duplicate entry ? do an nslookup and check it out.
No I think everything is fine now, just wanted to know why the two different host ID, one with a -42 and one with a -HA.
We had to pull the blades out of the racck and reseat them becuase the blades were running in "degredaded" mode due to a power outage.
Anyway, running get-vmhost is returning three names and ID's as it should.
