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

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)
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

vmware-cmd vmfs/volume/vmfslabel/VMName/VMName.vmx stop trysoft
vmware-cmd vmfs/volume/vmfslabel/VMName/VMName.vmx stop hard

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Andrew DoadesIT TechnicianCommented:
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
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.
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

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."
Bryan ButlerCommented:
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?
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.
touch-baseAuthor Commented:
Thx guys - splitting points here best I can
touch-baseAuthor Commented:
Thx guys

I also found this article helpful (for shuttng down the host)
Bryan ButlerCommented:
Thanks for the points, question, and excellent link.  
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.