Script to update hosts when using Auto Deploy(Stateless ESXi)

The attached script demonstrates how to automate host updates when using the Auto Deploy feature in vSphere 5.  Here's an excerpt from the comment at the top (take a look at the script for more details.)

# This script will help automate patching/updating large numbers of

# stateless hosts.  On the first invocation of the script, specify
# a cluster to remediate, the new image profile, and the old image mapping
# rule.  The script will update the deploy rule to use the new image profile.
# The script will then loop through all the hosts in the cluster,
# put them in maintenance mode, and reboot once the VMs are migrated off
# via DRS.  On subsequent invocations of the script, you can specify
# just the cluster (this assumes you have multiple clusters that leverage
# the same image profile deploy rule in Auto Deploy)

Here's an example of what using this script might look like:

Connect-VIServer MyVcHostName

Add-EsxSoftwareDepot https://hostupdate.vmware.com/software/VUM/PRODUCTION/main/vmw-depot-index.xml

Get-EsxImageProfile

# Scan through the list and pick the one you want

Get-DeployRule

# Note the name of your image profile assignment rule

.\ad-update.ps1 MyClusterName ESXi-5.0.0-XXXXXX-no-tools MyDeployRule

# Replace XXXXXX with the build number, or alternative image profile name as the second argument

You can also use your own custom image profiles by leveraging the image builder cmdlets.

Daniel

Awesome script Daniel.

This document was generated from the following discussion: javascript:;