VMware Cloud Community
Draelo
Contributor
Contributor

Using a batch script to shut down ESXi Host from a remote Windows computer

I have used a batch script to shut down a ESXI host from a remote Windows computer using Plink.exe.  The script is

start c:/plink.exe -v  -ssh <adminuser>@<ipaddress of server> -pw<password> poweroff -p

The script above works perfectly from  my computer, but when scheduling the batch script to run from our scheduling software it appears to run (both command prompt and plink run) but no command is sent to poweroff.

The sequence is the scheduling software runs the batch file on the remote Windows computer which runs plink to shutdown the ESXi host.

0 Kudos
2 Replies
dales123
Enthusiast
Enthusiast

What does the scheduled task code show after its run, also have you tried altering the batch file to pipe the results to a text file such as c:\plink.exe blah >> c:\output.txt .

also which account does the scheduled task run as and does that account have rights to the specific directories involved in your batch script?

Kind Regards Dale VCP3+5
0 Kudos
jrmunday
Commander
Commander

Agreed with dales123. Or logon interactively to the scheduling server so that you can execute this from a command prompt and see any errors.

In addition to this, you should concider using certificates for authentication so that you're not leaving clear text password in your scripts.

vExpert 2014 - 2022 | VCP6-DCV | http://www.jonmunday.net | @JonMunday77
0 Kudos