Create a Daily Schedule in Azure Automation Using PowerShell

In this blog post, we will show how to use Azure PowerShell to create a daily schedule in Azure Automation.

Azure Automation Schedules are a feature of the Azure Automation service that allows you to schedule the execution of various tasks, such as runbooks, PowerShell scripts, and other workflows. With this feature, you can automate the deployment and management of your Azure resources, and reduce the manual effort required to keep your infrastructure running smoothly.

PowerShell

The following code creates a daily schedule in Azure automation that runs every day. To execute this code, I’m using the Azure AZ module, version 9.4.0.

The first section of the code below sets the variables for the TimeZone the schedule will use, and in our case, it is the timezone you run the code from.

The second part of the script set the daily schedule to run every day at 18:00PM.

# Variables 
$TimeZones = ([System.TimeZoneInfo]::Local).Id
$AutomationAccountName="automation"
$rg_name="rgname"

# Daily 
$StartTime = (Get-Date "18:00:00").AddDays(1)
$EndTime = $StartTime.AddYears(4)
New-AzAutomationSchedule -AutomationAccountName $AutomationAccountName `
 -Name "Daily" -StartTime $StartTime -ExpiryTime $EndTime -DayInterval 1 -ResourceGroupName $rg_name -TimeZone $TimeZones

After you run the script, the schedule will be created immediately.

Summary

Azure Automation Schedules are a powerful feature of the Azure Automation service that can help you streamline the deployment and management of your Azure resources. By automating tasks such as runbooks and PowerShell scripts, you can reduce manual effort and improve the overall efficiency of your operations. With the ability to create custom schedules and integrate with other Azure services, Azure Automation Schedules provide a flexible and powerful tool for managing your automated tasks in the cloud.

Processing…
Success! You're on the list.


Posted

in

by

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.