0

I have a windows server 2012 with hyper-v on it,

My question here is how to stop a VM in hyper-v after like 30 days automatically, with out me touch anything, the point here that i have many clients and VMs, so i want the system do the overdue invoice stop service for me, is that possible ?

Thanks.

  • How will Hyper-V know that your customer invoice is overdue and that the VM should be shut down? Or do you just want Hyper-V to randomly shut down your VM's automatically? Your question doesn't make a lot of sense from a technical or operational standpoint. – joeqwerty Aug 30 '18 at 14:24
  • Hello, It's not like that i mean is there any way to stop any vm in my hyper-v after a month like i want the mv to stop after 30 days how my i schedule this , not the system me i will pick a time. – ahmed zeaad Aug 30 '18 at 17:43
0

Write a PowerShell script to run on the host, it can check a database for overdue invoices and if found stop the VM for that customer, like:

Stop-VM -Name foobar -Save

Schedule the script to run every day or once a week.

| improve this answer | |
  • Hello, "Stop-VM -Name foobar -Save" this command is working but how to make it run from it self let's say tomorrow or after week or month? is there any crontab like Linux ?? – ahmed zeaad Aug 31 '18 at 17:57
  • The Windows version of crontab is Task Scheduler you can use the GUI or PowerShell commands to set up a scheduled task to run your command whenever you like. Search online for help on how to do this. – Peter Hahndorf Sep 1 '18 at 10:27
0

You could create a scheduled task on the VM itself, using the "shutdown" command and set the task to run in 30 days. There is no built in functionality in Hyper-V to schedule VM shutdowns/restarts.

| improve this answer | |
  • Hello, you mean "shutdown" command for the host server or the vm and how i do it fot the vm ? – ahmed zeaad Aug 30 '18 at 14:06
  • Shutting your host server down will obviously stop all guests. I mentioned a task to run on the guest itself. If you are unfamiliar with setting up Windows scheduled tasks, you have some reading to do. – DanBig Aug 30 '18 at 19:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.