There are quite a few clicks needed to add a host to vCenter. If you are deploying multiple hosts to your environment you have many clicks ahead. You should script it! This PowerShell script will make adding multiple hosts to vCenter easy!
Let’s see it in action!
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
##################################################################### # Load VMware Plugins and connect to vCenter ##################################################################### Add-PSSnapin vmware.vimautomation.core ## Enter your vCenter here connect-viserver -server LABVC01.virtuallyboring.com ######################################################################## # Add Multiple Hosts to vCenter ######################################################################## # Variables ## You can use comma separated names or change to pull from a text file. Your pick. $ESXiHosts = "ESXi01.virtuallyboring.com" , "ESXi02.virtuallyboring.com" , "ESXi03.virtuallyboring.com" ## Enter the name of a Data Center or Host Cluster $ESXiLocation = "Nested ESXi Cluster" # Start Script $credentials = Get-Credential -UserName root -Message "Enter the ESXi root password" Foreach ($ESXiHosts in $ESXiHosts) { Add-VMHost -Name $ESXiHosts -Location $ESXiLocation -User $credentials.UserName -Password $credentials.GetNetworkCredential().Password -RunAsync -force Write-Host -ForegroundColor GREEN "Adding ESXi host $ESXiHosts to vCenter" } # End Script |