ESX Host Prep with PowerCLI
I often discuss ESX configuration with customers, and during a recent conversation the topic turned to Powershell and automation. This reminded of a script I wrote back in the vSphere 4.x days. I was able to locate the file, and with just 2 minor changes found it still works with vSphere 7. It is simple; but can save quite a bit of time. Since that is one of the fundamentals of automation – I thought it worthy of sharing.
vSphere does offer a feature called Host Profiles that can help ensure hosts have the same configuration. This feature does require Enterprise Plus licensing and can take some time to setup. For those that use vSphere Standard or the older Enterprise licensing – Host Profiles are not an option. That is where PowerCLI can be really useful!
I have 2 of the 3 Virtues of a Programmer. I initially wrote this script while building out hosts for a new cluster. The environment had a large number of VLANs that I had to manually create – over and over. it took forever! Hint – my virtues defined! The script saved me a ton of time, reduced mistakes and helped me see the value of automation.
- Adds portgroups to an existing VSS
- Configures and enables NTP
- Configures Syslog forwarding
I have posted the script on Github as an example for anyone new to Powershell/PowerCLI or to someone who just wants to save a few minutes. It is simple; but could easily be extended to meet the needs of nearly any environment.