Solved

Can I shutdown/startup a VM from a command prompt?

Posted on 2008-10-27
9
7,861 Views
Last Modified: 2012-05-05
I want to be able to shutdown and startup virtual machines on my ESXi server from another VM on the same server.
Obviously shutting down is easy enough.  But can I issue a command (automatically from a script) to the ESXi Host that starts up a VM hosted on it?  (Using only the free version of ESXi)
0
Comment
Question by:touch-base
  • 2
  • 2
  • 2
  • +2
9 Comments
 
LVL 4

Accepted Solution

by:
bmonroe44 earned 70 total points
ID: 22815124
vmware-cmd vmfs/volume/vmfslabel/VMName/VMName.vmx stop trysoft
vmware-cmd vmfs/volume/vmfslabel/VMName/VMName.vmx stop hard
0
 
LVL 10

Assisted Solution

by:Andrew Doades
Andrew Doades earned 60 total points
ID: 22815321
there is a command that comes with vmware server, not sure about ESXi

The following command will start the virtual machine named ScriptStart1:

vmrun -T server -h https://dhcp-122:8333/sdk -u root -p rootpass start [standard] ScripitStartVM1/ScriptStartVM1.vmx

the vmrun is a exe in the vmware program files folder.

Hope this helps
0
 
LVL 4

Expert Comment

by:bmonroe44
ID: 22815415
I neglected to say that with the free version of ESXi you will not be able to make a script as the command appliance is read-only. You can however issue commands through it to shutdown a VM as described above.
0
Free learning courses: Active Directory Deep Dive

Get a firm grasp on your IT environment when you learn Active Directory best practices with Veeam! Watch all, or choose any amount, of this three-part webinar series to improve your skills. From the basics to virtualization and backup, we got you covered.

 
LVL 1

Assisted Solution

by:hilmarusd
hilmarusd earned 60 total points
ID: 22817343
If you're using VMWare Server 2.0 (free version) on a windows server host, you can use the following:

C:\Program Files\VMware\VMware Server>vmrun -T server -h https://localhost:8333/sdk -u myusername -p mypassword stop "C:\Virtual Machines\ServerName\ServerName.vm"

Just make sure you have the right permissions for the username you specify or you'll get "Error: Insufficient permissions in host operating system."
0
 
LVL 16

Assisted Solution

by:Bryan Butler
Bryan Butler earned 60 total points
ID: 22818652
And to shut it down, I guess you would send the "shutdown" command.  So in powershell, that would be:

& "C:\Program Files\VMware\VMware Workstation\vmrun" -gu user -gp password runProgramInGuest "C:\VMs\Virtual Machines\VM177VistaBizBase\Windows Vista.vmx" C:\Windows\System32\shutdown

If you were running local.  I guess the -T and stuff if not.  Does that work?
0
 
LVL 1

Expert Comment

by:hilmarusd
ID: 22832644
I need to update my previous statement as that command line is invalid.  Here is the appropriate command line to start, stop, suspend, etc. a virtual server host in VMWare Server 2.0:

C:\Program Files\VMware\VMware Workstation\vmrun -T server -h https://localhost:8333/sdk -u myusername -p mypassword start "[standard] Coyote/Coyote.vmx"

Note that you need to put the storage device in square brackets before the name/vmxname.vmx.  Normally it's [standard] unless you're using a special storage device.  Also note the forward slash between virtual server name and the vmx filename instead of a back slash.
0
 
LVL 1

Author Closing Comment

by:touch-base
ID: 31510437
Thx guys - splitting points here best I can
0
 
LVL 1

Author Comment

by:touch-base
ID: 23052696
Thx guys

I also found this article helpful (for shuttng down the host)

http://communities.vmware.com/message/949876#949876
0
 
LVL 16

Expert Comment

by:Bryan Butler
ID: 23053486
Thanks for the points, question, and excellent link.  
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If we need to check who deleted a Virtual Machine from our vCenter. Looking this task in logs can be painful and spend lot of time, so the best way to check this is in the vCenter DB. Just connect to vCenter DB(default DB should be VCDB and using…
HOW TO: Install and Configure VMware vSphere Hypervisor 6.5 (ESXi 6.5), Step by Step Tutorial with screenshots. From Download, Checking Media, to Completed Installation.
Teach the user how to install and configure the vCenter Orchestrator virtual appliance Open vSphere Web Client: Deploy vCenter Orchestrator virtual appliance OVA file: Verify vCenter Orchestrator virtual appliance boots successfully: Connect to the …
Teach the user how to install log collectors and how to configure ESXi 5.5 for remote logging Open console session and mount vCenter Server installer: Install vSphere Core Dump Collector: Install vSphere Syslog Collector: Open vSphere Client: Config…

856 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question