Using ESXCLI Commands in ScriptsLast Updated December 16, 2024
Most administrators run scripts to
perform the same task repeatedly or to perform a task on multiple hosts. You can run ESXCLI
commands from one administration server against multiple target servers.
For example, when a new data
store becomes available in your environment, you must make that data store
available to each
ESXi
host. The
following sample script illustrates how to make a NAS data store available to
three hosts (esxi_server_a, esx_server_b, and esxi_server_c
).
The sample assumes that a configuration file
/home/admin/.visdkrc.<
exists for
each host. For example, the configuration file for hostname
>esxi_server_a
has
the following contents. The script adds the NAS data
store to each host defined in
VIHOSTS
.