You can use the vmcli command-line utility in Workstation Pro
to interact with the hypervisor from the Linux terminal window or at the Windows command prompt. By using vmcli commands, you can perform various virtual machine operations like creating new virtual machine or virtual machine template.
Running the vmcli command-line utility
You can run the vmcli from the Linux terminal window or at the Windows command prompt. You can also create scripts to run multiple commands.
To run the vmcli command and get the syntax to use the available functionality, run the following command.
vmcli --help
After you run this command, you receive the following output.
vmcli --help Usage: vmcli [-v | --version] [<vmx location>] <module> <command> [<args>] [--verbose] [-h | --help] [<vmx location>] Top level arguments: -v, --version Display the version information. Global arguments: <vmx location> (required for commands working with VMs) Location of the vmx file to work with. Can be the first or last argument on the command line. --verbose Enable verbose logging. -h, --help Display the help information Available modules: Chipset Chipset options. ConfigParams Set VM configuration parameters. Disk Module to perform disk operations. Ethernet Setup the ethernet configuration in the guest. Guest guest ops HGFS HGFS options. MKS Mouse, keyboard and screen operations. Nvme Setup NVME ports in the guest. Power Set the power state of the vm. Sata Setup SATA ports in the guest. Serial Setup serial ports in the guest. Snapshot Snapshot configuration Tools Tools related configuration. VM VM related Operations VMTemplate Create and Deploy vm template VProbes Setup VProbes in the guest
To learn more about the syntax of each module or operation, for example the Power module, you can run the following command.
vmcli Power --help
After you run this command, you receive the following output.
vmcli Power --help Usage: vmcli [-v | --version] [<vmx location>] Power [--verbose] [-h | --help] query Start Stop Pause Reset Suspend Unpause [<vmx location>] Top level arguments: -v, --version Display the version information. Global arguments: <vmx location> (required for commands working with VMs) Location of the vmx file to work with. Can be the first or last argument on the command line. --verbose Enable verbose logging. -h, --help Display the help information Module: Power Set the power state of the vm. Arguments available to module "Power": query Query the power state of the VM. Start Start the virtual machine. Stop Stop the virtual machine. Pause Pause the virtual machine. Reset Rest the virtual machine. Suspend Suspend the virtual machine. Unpause Unpause the virtual machine.
You can also retrieve usage information for a specific operation of any module.
vmcli Power query --help
After you run this command, you receive the following output.
vmcli power query --help Usage: vmcli [-v | --version] [<vmx location>] Power query [--verbose] [-h | --help] [-f | --format <2, 1, 0>] [<vmx location>] Top level arguments: -v, --version Display the version information. Global arguments: <vmx location> (required for commands working with VMs) Location of the vmx file to work with. Can be the first or last argument on the command line. --verbose Enable verbose logging. -h, --help Display the help information Module: query Query the power state of the VM. Arguments available to module "query": -f, --format <2, 1, 0> Sets the format of the output.
Using vmcli to create a template from an existing virtual machine
You can create a virtual machine template from an existing virtual machine. You can later use this template to create a new virtual machine with the same configuration.
You can use the following syntax.
vmwcli <source vmx path> vmtemplate create -p <template vmtx path> -n <template name>
Variable | Description |
---|---|
source vmx path | Path to the source virtual machine vmx from which the template will be created. |
template vmtx path | Full path to the new vmtemplate folder along with file name with the .vmtx extension. Example: |
template name | Name of the tamplate. |
Using vmcli to deploy a virtual machine template
You can deploy the VMTemplate
that was created by the vmcli command. By using the following syntax, you can create a new virtual machine from the specified VMTemplate
at the same location.
VMTemplate Deploy -p <Full file path of vmtx file of existing VM template>
Using vmcli to create a new virtual machine
You can use the following syntax to create a new virtual machine.
VM Create -n <vm name> -d <path where vm will be created> -g <guest operating system>
VM Create -n myVM -d ~/Desktop/ -g windows9-64
Example of creating a virtual machine and attaching an ISO to it
After performing the following steps, you can add a newly created virtual machine to the Virtual Machine Library and then power the virtual machine on to start the guest installation process by using the ISO file. You can use the syntax from the following example.
echo "----creating VM-----" vmcli VM Create -n windowstest -d ~/Desktop/test -g windows9-64 vmcli ConfigParams SetEntry displayName "windowstest" ~/Desktop/test/windowstest.vmx echo "----create Nvme vmdk related things-----" vmcli nvme SetPresent nvme0 1 ~/Desktop/test/windowstest.vmx vmcli Disk SetBackingInfo nvme0:0 disk windowstest.vmdk 1 ~/Desktop/test/windowstest.vmx vmcli Disk SetPresent nvme0:0 1 ~/Desktop/test/windowstest.vmx echo "----create sata disk for iso mounting-----" vmcli Sata SetPresent sata0 1 ~/Desktop/test/windowstest.vmx vmcli Disk SetBackingInfo sata0:0 cdrom_image ~/Documents/iso/22621.1.220506-1250.ni_release_CLIENT_ENTERPRISES_OEM_x64FRE_en-us.iso 1 ~/Desktop/test/windowstest.vmx vmcli Disk SetPresent sata0:0 1 ~/Desktop/test/windowstest.vmx echo "----create ethernet related things-----" vmcli Ethernet query ~/Desktop/test/windowstest.vmx vmcli Ethernet SetVirtualDevice ethernet0 vmxnet3 ~/Desktop/test/windowstest.vmx vmcli Ethernet SetConnectionType ethernet0 nat ~/Desktop/test/windowstest.vmx vmcli Ethernet SetAddressType ethernet0 generated "" ~/Desktop/test/windowstest.vmx vmcli Ethernet SetLinkStatePropagation ethernet0 true ~/Desktop/test/windowstest.vmx vmcli Ethernet SetPresent ethernet0 1 ~/Desktop/test/windowstest.vmx vmcli ConfigParams SetEntry bios.bootOrder "cdrom,hdd" ~/Desktop/test/windowstest.vmx echo "---------Done-------"