How to Add ESXi Hosts to vCenter using PowerShell

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!

In my environment I deployed three new ESXi hosts (ESXi01-03.virtuallyboring.com) and I want to add them to my cluster named Nested ESXi Cluster:

PS Add Hosts to vCenter 1 - Empty Cluster

Open the script in PowerShell ISE as we need to update a few variables highlighted in yellow:

  1. Update the vCenter name to your vCenter name
  2. In the Variables section update $ESXiHosts to the names of the hosts you want to add
  3. Update the $ESXiLocation to the name of the Data Center or Host Cluster you want the hosts added to

You are now ready to run the script! You should receive a popup requesting the root credentials of the ESXi hosts. The password never enters plain text and remains encrypted and secure (See screenshot below):

PS Add Hosts to vCenter 4 - Script Output

Popup requesting ESXi root credentials:

PS Add Hosts to vCenter 2 - Credential Request

Over in vCenter you should see Add Host tasks with the hosts appearing under your specified location!

PS Add Hosts to vCenter 3 - Hosts Added

This script should make it very easy to add multiple hosts to your environment in one swoop!

2 thoughts on “How to Add ESXi Hosts to vCenter using PowerShell”

  1. Hi,
    This is krish here please update me after adding .vmx file into inventory the the vm should power on automatically using powershell

    Reply

Leave a Reply