2
votes

I would like to schedule stop/start Azure virtual machines with an Azure automation runbook.

This is what I've done so far. Created new automation runbook from gallery in Azure management portal. Chose 'Stop Windows Azure Virtual Machines on a Schedule' from 'VM Lifecycle Management' (it's this script). Runbook created, went to Author page of this runbook and pressed test. Provided the necessary parameters. Then several errors appeared on the output, starting with this:

1/21/2015 9:15:26 AM, Error: New-ScheduledTaskTrigger : The term 'New-ScheduledTaskTrigger' is not recognized as the name of a cmdlet, function, 
script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is 
correct and try again.
At Stop-AzureVMsOnSchedule:41 char:41

Why this cmdlet cannot be found? I tried to upload the ScheduledTasks module in assets menu from my machine (c:\Windows\SysWOW64\WindowsPowerShell\v1.0\Modules\ScheduledTasks) but it complained about that the format is invalid.

Could you give me a hint why this script is not working or do you know an alternative what to use for scheduling tasks in an automation runbook?

2

2 Answers

3
votes

"Stop Windows Azure Virtual Machines on a Schedule" is an Azure PowerShell script not designed to work as a runbook in Azure Automation. You can see that when you attempt to import it from gallery:

note when you import 'Stop Windows Azure Virtual Machines on a Schedule' script

I recommend instead you import the runbook for stopping VMs created by jeffbow. By hooking this runbook up to an Azure Automation schedule asset you will be able to schedule shutting down your Azure VMs:

a good runbook to use for stopping Azure VMs from Azure Automation

0
votes

This script needs to be edited to work in Azure Automation.

New-ScheduledTaskTrigger does not work in Azure Automation environment. To schedule Automation runbook, use New-AzureAutomationSchedule

Details at https://msdn.microsoft.com/en-us/library/dn690271.aspx