Evaluate Weigh the pros and cons of technologies, products and projects you are considering.

VSphere Host Profiles vs. PowerCLI: The war for automation supremacy

Both vSphere Host Profiles and PowerCLI scripts automate the host-provisioning process, but each tool has strengths and limitations.

One of my occupational hazards is constantly being asked which technologies to use for virtualized environments....

Customers often ask whether to use vSphere Host Profiles or PowerCLI scripts to configure ESX or ESXi hosts.

For me, automating the build process is the first step toward ensuring consistency and reliability. It also aids the rollout of a new product version or rebuilding a failed host.
Of course, some folks say they don't use vSphere Host Profiles or PowerCLI scripts.

They have only four ESX hosts to configure, for example. And then they mistype a domain name server entry or forget to set the network time protocol consistently.

With an automated build process, you'll save time by blowing up a configuration and starting over, rather than upgrading or repairing a host -- which can be time consuming. You can trust that your script will bring the hosts to their original state when ESX/ESXi was first installed and configured.

Host Profiles, on the other hand, appeal to folks with a pathological aversion to scripting environments. Through vCenter Server, administrators can create host templates with preconfigured settings, called a host profile, and quickly apply them to new hosts. So which method should you use: PowerCLI or Host Profiles?

VSphere Host Profiles: Pros and cons
VSphere Host Profiles' biggest advantage is the ability to copy the configuration of existing vSphere host and apply it to another host. It's even better when your server vendor has a hardware profile system for configuring a blade server that seamlessly integrates with a host profile. This combination greatly reduces the configuration time and speeds deployment.

Sadly, vSphere Host Profiles is far from perfect. As a configuration tool, it currently and inexplicably doesn't offer options for setting up VMware iSCSI Initiator. (The operative word in the last sentence is currently.)

Also, a host profile can be applied only when vSphere hosts are in maintenance mode, which entails the migration of all VMs to another host with vMotion. This limitation is fine if you're working on a brand-new server that hasn't been configured to support virtual machines. But it can be a problem if you have 32 hosts to reconfigure. My point is that vSphere Host Profiles is a great configuration tool, but it's not really viable as a reconfiguration tool.

Ultimately, this debate may be meaningless to you, however. Host Profiles is available only to Enterprise Plus customers. In contrast, VMware PowerCLI -- one for most useful toolkits -- is free. It's just a shame that VMware hobbled PowerCLI's functionality in free edition of VMware ESXi. You can retrieve information with PowerCLI but you can't change configurations.

Advantages of PowerCLI
Suppose your boss says that a new iSCSI target settings needs to be created on your 32-node ESX host cluster. Your options are limited because Host Profiles doesn't currently configure the ISCSI stack in ESX. (Again, notice the word currently.)

You could ditch iSCSI and move to a different storage protocol, such as Fibre Channel or Network File System. If you went down this route, expect your boss to call those nice men with the white coats to take you to the happy place for a couple of months.

The following approach would be more astute:

  1. Open PowerCLI.
  2. Log in to the vCenter Server that manages the cluster.
  3. Run the script below:

$targets = "","", ""

$esxHosts = Get-VMhost
foreach($esx in $esxhosts){
$hba = $esx | Get-VMHostHba -Type iScsi
foreach($target in $targets){
if(Get-IScsiHbaTarget -IScsiHba $hba -Type Send | Where {$_.Address -cmatch $target}){
Write-Host "The target $target does exist on $esx" -ForegroundColor Green
Write-Host "The target $target doesn't exist on $esx" -ForegroundColor Red
Write-Host "Creating $target" -ForegroundColor Yellow
New-IScsiHbaTarget -IScsiHba $hba -Address $target | Out-Null
Write-Host "done..." -ForegroundColor Green

  1. Drink a cup of coffee and come back in 5 minutes to find the job done.

You probably think I'm a pretty smart guy after writing script a like the one above. But you'd be dead wrong. I am an expert at cut and paste. There's a vast community of PowerCLI wonks who are more than happy to share their scripts. The one above actually comes from Arne Fokkema's site, ICT-FREAK.NL. (I'm sure he's a great guy and not at all a wonk!)

The value of automation
The one thing you learn as an instructor is the importance of automated builds. If you ever attend a training course where the instructor built the classroom environment, it's always a hot topic -- because, historically, this task always falls into the category of unpaid overtime.

Instructors quickly look to automate the classroom-setup process. At the same time, training course labs are normally consistent from one class to the next. So there's another huge advantage for standardization from Day One. As an old friend that used Unix once said to me, "If I done it twice, I've scripted it."

But it's also reasonable to use both PowerCLI and Host Profiles together. You could use PowerCLI as your main configuration and reconfiguration tool and use Host Profiles for consistency checks. Host Profiles has a validation process that can check if the host matches the host profile. You can run these checks on a weekly or monthly basis to see if any ad-hoc administrative changes were made to the standard build.

Dig Deeper on Creating and upgrading VMware servers and VMs