ESXi CLIativity – Part 2

In my previous post, I showed you how to run scripts on the ESXi CLI with minimal intervention. In this episode, I will show you another example, which will also make use of PowerCLI and one of the PuTTY utilities.

The scenario; Now and then servers need all kind of upgrades; BIOS, NIC and HBA firmware to name a few. Hardware vendors usually offer multiple ways and additional tooling to perform those updates. As an example HPE provides packages, called Smart Components which can be installed from the Operating System layer, in the past limited to Windows and some Linux flavours, today also for ESXi.

Smart Components for ESXi come in the form of a .zip file, named . The .zip contains an executable called: CPxxxxxx.vmexe, the firmware CPxxxxxx.vmfile, some additional .xml and .json files and a README.txt with installation instructions. Chances are that during an upgrade cycle of a cluster multiple components need a firmware upgrade, it will become clear that this is a time consuming task. So time for some automation!

In this example, we use the same setup as in the previous example. Before we can start we need to make some arrangements.

  1. For each type of host we need to determine which firmware we need and download the Smart Components.
  2. Now on the Windows workstation create a new folder. Name the folder accordingly to the server hardware, e.g. “DL380G9”.
  3. Unzip the Smart Components and place the .vmexe, .vmfile and the .xml files in the newly created folder.
  4. Repeat for each Smart Components.

The first part is an PowerShell script which can be found here.
is script is very basic and will (after providing a host name and credentials) run against a single ESXi host. Some brief explanation:

Lines 5-7: Host information will be retrieved, needed to determine the server model (in case you run multiple types) and SSH will be enabled.

For each server model, two lines of code will do all the work.

Line 11 (17): The pscp.exe utility will transfer all the Smart Component files to the ESXi host and place in the /tmp folder.
Line 12 (8): the plink.exe
runs the firmware.plink file which will take care of all the actions on the ESXi host
Lines 3-13: The scrip is created, which will be execute on line 15.

The script performs the following actions:

Line 3: make all .vmexe files executable.
Line 4: place all .vmexe in file “firmware”, which we will use in the for loop starting on line 5.
Line 6: write some basic logging to log file “log.txt”.
Line 7: runs the actual .vmexe file. Added option “-s” for a silent installation.
Line 9: after finishing the for loop, all CP* files will be removed.
Line 10: checks if the ESXi host is in maintenance mode and if true, will perform a reboot (line 12).

I hope this example will give you inspiration for other applications. In case you have an example or a suggestion, please let me know. I thank you for reading.


2 Responses to ESXi CLIativity – Part 2

  1. […] previous post in this series, one and two, I showed you some examples how to run ESXi CLI commands on a more relaxed way with use of the […]

  2. […] the next part, I will show some more examples. As always, I thank you for […]

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: