Scheduling a Runbook

 

Updated: May 13, 2016

Applies To: Windows Azure Pack for Windows Server

To schedule a runbook in Service Management Automation to start at a specified time, you link it to one or more schedules. A schedule can be configured to either run one time or recurring every specified number of days. A runbook can be linked to multiple schedules, and a schedule can have multiple runbooks linked to it.

Creating a Schedule

You can either create a new schedule with the Management Portal or with Windows PowerShell. You also have the option of creating a new schedule when you link a runbook to a schedule using the Management Portal.

To create a new Schedule with the Management Portal

  1. In the Management Portal, select Automation.

  2. Select the Assets tab.

  3. At the bottom of the window, click Add Setting.

  4. Click Add Schedule.

  5. Type a Name and optionally a Description for the new schedule.

  6. Select whether the schedule will run One Time or Daily.

  7. Specify a Start Time and the other options depending on the type of schedule that you selected. The time zone of the start time will match the time zone of the local computer.

To create a new Schedule with Windows PowerShell

You can use the Set-SmaSchedule cmdlet to create a new schedule or modify an existing schedule in Automation. You must specify the start time for the schedule and whether it should run one time or daily.

The following sample Windows PowerShell commands create a new schedule called My Daily Schedule that starts on the current day and continues for one year every day at noon.

$webServer = 'https://MyServer'  
$port = 9090  
$scheduleName = 'My Daily Schedule'  
$startTime = (Get-Date).Date.AddHours(12)  
$expiryTime = $startTime.AddYears(1)  
  
Set-SmaSchedule –WebServiceEndpoint $webServer –Port $port –Name $scheduleName –ScheduleType OneTimeSchedule –StartTime $startTime –ExpiryTime $expiryTime –DayInterval 1  

Linking a Schedule to a Runbook

A runbook can be linked to multiple schedules, and a schedule can have multiple runbooks linked to it. If a runbook has parameters, then you can provide values for them that are used when the runbook is started. You must provide values for any mandatory parameters.

  1. In the Management Portal, select Automation.

  2. Select the Runbooks tab.

  3. Click on the name of the runbook to schedule.

  4. Click the Schedule tab.

  5. If the runbook is currently linked to a schedule,.

  6. Click Link at the bottom of the window. Then either click Link to a New Schedule and follow the dialog box to create a new schedule, or click Link to an Existing Schedule and select a schedule that has already been created.

  7. If the runbook has parameters, you will be prompted for their values.

You can use the Start-SmaRunbook with the ScheduleName parameter to link a schedule to a runbook. You can specify values for the runbook’s parameters with the Parameters parameter. See Starting a Runbook for more information on specifying parameter values.

The following sample commands show how to link a schedule to a runbook.

$webServer = 'https://MyServer'  
$port = 9090  
$runbookName = "Test-Runbook"  
$scheduleName = "Sample-DailySchedule"  
  
Start-SmaRunbook –WebServiceEndpoint $webServer –Port $port –Name $runbookName –ScheduleName $scheduleName –Parameters $params  
  

See Also

Service Management Automation
Runbook Operations (old) [SMA]
Starting a Runbook