Upload and Install ESXi Patch via PowerCLI

The Script I have created a few weeks ago is a little bit more than a simple Upload and Install ESXi Patch via PowerCLI. The Script uses for the installation of the Patch Bundle the VMware PowerCLI ESXCLI v2 Cmdlet (no SSH Connection for esxcli). This method forces the installation of the VIBs in the Patch Bundle and allows also a downgrade of the Version. The Install-VMHostPatch Cmdlet, which is common for the Patch installation with PowerCLI, only applies version updates and does not force a downgrade of a VIB.

Top vBlog 2018 Voting

Take the survey to cast your ballot and reward the best bloggers for their hard work and dedication by letting them know that you appreciate them.

Upload and Install ESXi Patch via PowerCLI - Log Output

As a goodie does the script handle the respond of the Patch installation and detects if a reboot is required. If so the host will be restarted.

My initial use case for this script was to standardize all NIC drivers is the whole vCenter inventory. To get this done IO have used my  NIC Driver and Firmware function to get all ESXi hosts with wrong NIC driver Version (and also wrong firmware) to get them all to the recommended version (up- and downgrade was necessary).

Upload and Install ESXi Patch via PowerCLI Script

The PowerCLI script installs the Patch bundle from a Datastore on all ESXi Hosts of the vSphere Cluster in Maintenance Mode. The file must be uploaded to the Datastore before the installation.

Variables:

Name Description Example
ClusterName Name of the vSphere Cluster “Compute01”
LocalPath Local path to the Patch Bundle “D:\Image\HPE-20180220.zip”
DepotName Name of the Depot Zip file “HPE-20180220.zip”
TempDatastoreName Name or wildcard of the Datastore “LOCAL*”

For the upload of the ZIP file i use the New-DatastoreDrive and Copy-DatastoreItem Cmdlets. After that the Installation will be done by the Get-ESXCLI -V2 Cmdlet.

This Script is also available as GitHub Gist

Leave a Reply