VMWare Server Tip: Remotely Monitor And Administer Virtual Machines From The Command Line


vmwarelogo.jpgVMWare GUI interface is great for building Virtual Machines and making any configuration changes when needed. After the VM is running and configured to your preference, there is little need to use the GUI interface except for starting VM's when they are powered off. Instead of using the GUI, VMWare provides an easier method to administer and manage VM's from the command line using vmware-cmd command.


vmware-cmd has two modes of Operations (see further below for entire list of parameters for vmware-cmd):

Operations on a Virtual Machine syntax – vmware-cmd <options> <vm-cfg-path> <vm-action> <arguments>

Operations on VMWare Server syntax – vmware-cmd -s <options> <server-action> <arguments>

and can be found on Windows at <install location>\VmWare\VMWare Server and on Linux at /usr/bin

The first parameter you want to run is vmware-cmd -l which lists all registered VMs on the local computer. Running this command first will display the path of each VM config file, which is needed for most of the commands. On my Windows Vista Computer, running this command returns:

> C:\Program Files\VMware\VMware Server>vmware-cmd -l
> C:\Other\Virtual Machines\WTN1\Windows XP Professional.vmx
> C:\OTHER\Virtual Machines\WTN2\Ubuntu.vmx

(Note: On Windows OS's, if you do not CD (Change Directory) to the location of vmware-cmd, don't forget to use quotes when there are spaces in the path – "C:\Program Files\VMware\VMware Server\vmware-cmd" -l)

To start a Virtual Machine, the sytax is: vmware-cmd <vm-cfg-path> start

So on my computer, I would run the following command to start the Virtual Machine named WTN1:

vmware-cmd "C:\OTHER\Virtual Machines\WTN1\Windows XP Professional.vmx" start

To stop WTN1, I would run: vmware-cmd  "C:\OTHER\Virtual Machines\WTN1\Windows XP Professional.vmx" stop

What if I did not know if the VM was running or stopped? In this case, I would use the getstate parameter which will tell me the state of the machine by running: vmware-cmd "C:\OTHER\Virtual Machines\WTN1\Windows XP Professional.vmx" getstate

The command would return: getstate() = off telling me that the VM is is powered off.

When managing VM's on a remote computer, use the following options:

vmware-cmd -H <hostname> -U <username> -P <password>

Where H is the host name of the remote computer, U is the username or account on the remote computer and P is the password.

If the VM WTN1 was on a remote computer named PC1 and I wanted to start it up, I would enter the command:

vmware-cmd -H PC1 -U mike P watchingthenet "C:\OTHER\Virtual Machines\WTN1\Windows XP Professional.vmx" start

Managing Virtual Machines from the command line has many benefits, including remote administration , status, and creating scripts or batch files that can be used to automate backups of VM's by shutting down and powering off. While using the GUI interface is convenant, using vmware-cmd command can provide for quick access and execution.

Below is the list of options/parameters used with vmware-cmd. To output the list on your Computer, run vmware-cmd -h

Connection Options:
-H <host> specifies an alternative host (if set, -U and -P must als
o be set)
-O <port> specifies an alternative port
-U <username> specifies a user
-P <password> specifies a password
General Options:
-h More detailed help.
-q Quiet. Minimal output
-v Verbose.

Server Operations:
vmware-cmd -l
— lists the registered VMs
vmware-cmd -s register <config_file_path>
— registers a VM
vmware-cmd -s unregister <config_file_path>
— unregisters a VM
vmware-cmd -s getresource <variable>
— retrieves a server resource
vmware-cmd -s setresource <variable> <value>
— sets a server resource

VM Operations:

vmware-cmd <cfg> getconnectedusers
vmware-cmd <cfg> getstate
— gets the execution state of the VM
vmware-cmd <cfg> start <powerop_mode>
— powers on or resumes a VM
vmware-cmd <cfg> stop <powerop_mode>
— stops a VM
vmware-cmd <cfg> reset <powerop_mode>
— resets a VM
vmware-cmd <cfg> suspend <powerop_mode>
— suspends a VM
vmware-cmd <cfg> setconfig <variable> <value>
— sets a configuration variable
vmware-cmd <cfg> getconfig <variable>
— retrieves the value for a configuration variable
vmware-cmd <cfg> setguestinfo <variable> <value>
— sets a guest info variable
vmware-cmd <cfg> getguestinfo <variable>
— retrieves the value for a guest info variable
vmware-cmd <cfg> getid
— retrieves the VM id
vmware-cmd <cfg> getpid
— retrieves the process id of the running VM
vmware-cmd <cfg> getproductinfo <prodinfo>
— gets various product information
vmware-cmd <cfg> connectdevice <device_name>
— connects a virtual device to a VM
vmware-cmd <cfg> disconnectdevice <device_name>
— disconnects a virtual device from a VM
vmware-cmd <cfg> getconfigfile
— retrieves the path to the configuration file
vmware-cmd <cfg> getheartbeat
— retrieves the heartbeat value of the guest OS
vmware-cmd <cfg> getuptime
— retrieves the uptime of the guest OS
vmware-cmd <cfg> getremoteconnections
— retrieves the number of remote connections to a VM
vmware-cmd <cfg> gettoolslastactive
— retrieves the number of seconds since last notification from the tools
vmware-cmd <cfg> getresource <variable>
— retrieves a VM resource
vmware-cmd <cfg> setresource <variable> <value>
— sets a VM resource
vmware-cmd <cfg> setrunasuser <username> <password>
— sets the user that the VM runs as
vmware-cmd <cfg> getrunasuser
— retrieves the user that the VM runs as
vmware-cmd <cfg> getcapabilities
— retrieves the access permissions of the current user on a VM
vmware-cmd <cfg> addredo <disk_device_name>
— adds a redo log to a virtual disk
vmware-cmd <cfg> commit <disk_device_name> <level> <freeze> <wait>
— commits the redo log of a virtual disk
vmware-cmd <cfg> answer
— answers a question for a VM requesting input

Filed under VMware Tips by  #

Leave a Comment

Fields marked by an asterisk (*) are required.

Subscribe without commenting