j0sh1
Contributor
Contributor

Autostart - Shutdown scheduling of vms

Hey there,

is there any possibility to schedule shutdown and start of vms automatically?

It would be great if someone of you have a good hint for me

best regards

jack

Tags (1)
0 Kudos
8 Replies
ThompsG
Virtuoso
Virtuoso

Hi J0sh1 and welcome to the community Smiley Happy

Yes there is - you can use Schedule Tasks to achieve this by having a task that changes the power state of VMs. Rather than try and explain take a look at this link: vSphere 6.0 Documentation Center

Hope this helps.

0 Kudos
EXPRESS
Enthusiast
Enthusiast

I have a powershell script which i was able to get from the community several years ago and still use it to this day. I schedule a shutdown and startup every weekend.

Thank you, Express
0 Kudos
j0sh1
Contributor
Contributor

ThompsGHi ThompsG

Thanks for your reply - but as i understand from the documentation - the webclient is only for licensed esxi hosts. Unfortunately im using the free esxi 6 host  😕



0 Kudos
j0sh1
Contributor
Contributor

That sounds intresting - where does the script run and could you provide me your script?

0 Kudos
EXPRESS
Enthusiast
Enthusiast

Shutdown using...

# This Script will PowerOff VM's listed in c:\vmlist.txt

add-PSSnapin VMware.VimAutomation.Core | Out-Null

Connect-VIServer vcenter-server -User domain\adm -Pass 123456

# Get VM's from c:\vmlist.txt then ShutDown each one.

Get-Content C:\Scripts\vmlist.txt | % { Get-VM $_ | Shutdown-VMGuest -Confirm:$false }

# Get VM's from c:\vmlist.txt then Restart each one.

# Get-Content C:\vmlist.txt | % { Get-VM $_ | Restart-VMGuest -Confirm:$false }

# Email log file

send-mailmessage -SmtpServer "smtp.domain.com" `

-from "VM-ShutDown <machine@domain.com>" `

-to "Admin@domain.com>" `

-subject "ShutDown_$((get-date).toString('MM-dd-yyyy_hh:mmtt'))" `

-body "VM ShutDown Script has been sent"

Thank you, Express
0 Kudos
j0sh1
Contributor
Contributor

Thanks for your reply.

But you always need a Windows Client to run this script or im wrong?

Actually I need a possibility to manage the scheduled task just from the bare ESXi instance - is there any way to do that?

Cheers

0 Kudos
rampeter
Enthusiast
Enthusiast

Assume that if we have SCCM auto reboot can be enabled ,there is any pros by doing this in Vcenter level?

0 Kudos
amansapra19
Enthusiast
Enthusiast

You can achieve this by:

1. Creating a scheduled task in vCenter: Home > Scheduled Tasks > New

2. Writing a powershell script and creating a scheduled task in a Windows server to trigger the script.

0 Kudos