Provison ESX Hosts through Powershell

The VI Toolkit community has been getting busier and busier of late, I think even LucD is taking 5 minutes to respond rather than his normal 2 minute answers!

There is one area of the VI Toolkit communities that I feel does not get enough publicity, there have been many scripts written by the community and members of VMware that are stored in the documents area of the community.

I will make it my aim to try and bring some of these fantastic scripts out into the open as the scripts and the people who wrote these scripts have done some amazing coding to help everyone else.

For example: NAEPS (Not Another ESX Provisioning Script) by SCampbell
This is one of a few scripts that he has written, I’m sure I will go over the others in due course.  If nothing it gives a great insight into what can be done with the VI Toolkit.

This script can be used to configure the ESX servers being deployed, it includes some wonderful settings:

* Configure the license server
* Upload signed SSL key and certificate files to the ESX server
* Rename all local datastores to try to reduce the accidental deployment to local stores
* Configure the firewall for NTP and updateManager
* Targeted for ESX although there is also a nod to ESXi provisioning
* Configure the environment for our special case where the VCS-ESX communications are on an isolated network
* Reset the root password
* Configure networks
* Joining to VCS servers
* Configuring NTP, DNS, domain, name, IP’s etc.

And a separate isolated VMotion network

* Rescan the HBAs

Some interesting concepts explored here, although hints of topics on these throughout the forums

* Upload files to an https server with a self-signed SSL certificate
* Finding the local datastores on an ESX server
* Accessing and modifying the firewall configuration
* Dealing with Passwords entered with the Read-Host -asSecureString

Some of his caveats:

* This is my first significant Powershell, .Net and VI project. I am sure many of you will cringe when you look at the arcane methods I found.
* We do a manual install of ESX rather than using kickstart. I expect we’ll head towards ESXi and this work wouldn’t have paid back. This script is run immediately after the reboot following the installation.
* It works pretty well in our target environment, but there is no guarantee or warranty it will work in yours.
* The upload stuff works here works for fairly small files. (file size=memory consumed) Carter Shanklin and I are working to improve the upload process. Watch Carter’s (c_shanklin) blog and his VI Toolkit Extensions at

A few features for the next version of this script – perhaps in another life:

* It should really attach the server to an Update Manager baseline and remediate.
* Replace all the anachronisms with the best-practice methods
* Configure a VMKernel network and gateway on the Management VLAN
* A way cool Windows.Forms with drop-down lists to capture the information
* Automatically download backup ESXi configuration file to the local disk

As you may have noticed all the messages in this script are simply dumped to the console, rather than explicitly output with Write-Host. You can redirect this to a log file and still see the console messages by invoking the script as follows:

So if that doesn’t wet your appetite for the great scripts on the site stay tuned for my next post where I will add another script, this set of posts is mainly to fill time while I write my next reporting script which is already looking quite cool and I’m really enjoying writing.

Download the script and read more here:

One thought on “Provison ESX Hosts through Powershell”

  1. Thanks for the mention! It’s amazing what you come across on the Internet.

    Have you seen anything on automating the installation of ESXi Installable? I want to do a completely unattended install (not PXEBoot) of ESXi and haven’t had much luck finding out what I need to crack open in the iso to replace the prompts (IP, etc) with answers.

    Once the installation is complete, I’ll then run a version of the configureESX.ps1 script. It already works pretty well for ESXi 4, but I’ll tweak it for PowerCLI 4.

    Thanks for this.

Leave a Reply