Solved

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

Posted on 2008-10-27
9
7,848 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
 
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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
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

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

One of the new features of a version 7.0 or later virtual machine, supported in VMware vSphere 4.1, 5.0 or the VMware vSphere Hypervisor ESXi 4.1, ESXi 5.0 often overlooked by VMware Administrators is the ability to add and connect USB devices conne…
It Is not possible to enable LLDP in vSwitch(at least is not supported by VMware), so in this article we will enable this, and also go trough how to enabled CDP and how to get this information in vSwitches and also in vDS.
Teach the user how to edit .vmx files to add advanced configuration options Open vSphere Web Client: Edit Settings for a VM: Choose VM Options -> Advanced: Add Configuration Parameters:
Teach the user how to configure vSphere clusters to support the VMware FT feature Open vSphere Web Client: Verify vSphere HA is enabled: Verify netowrking for vMotion and FT Logging is in place or create it: Turn On FT for a virtual machine: Verify …

708 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now