Want to preface that scripting and automation is weak but doing my best to learn.
I have 3 hosts I want to add to a cluster that is already created in vCenter. While the following can be better this is the best I can scrap together..haha
##Adding ESXi hosts to a Cluster Object already created in vCenter##
foreach ($securehost in $securehosts) {
Add-VMHost -Server vcenter.khizeran.com -Name $securehosts -Location "Secure Cluster" -User root -Password "VMware1!" -Force }
When I ran this line, with the following, it ran but only added one host, but something else went weird with my variable, I'm getting confused with what is in my foreach command. I know I typed in the same variable in it, and that does not make sense.
PS C:\Windows\system32> foreach ($securehosts in $securehosts) {
Add-VMHost -Server vcenter.khizeran.com -Name $securehosts -Location "Secure Cluster" -User root -Password "<password>" -Force }
Name ConnectionState PowerState NumCpu CpuUsageMhz CpuTotalMhz MemoryUsageGB MemoryTotalGB Version
---- --------------- ---------- ------ ----------- ----------- ------------- ------------- -------
esxi16.khizeran.com Connected PoweredOn 2 0 4798 0.000 7.999 7.0.3
Any help would be greatly appreciated.