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.
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.
$TimeZones = ([System.TimeZoneInfo]::Local).Id
$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.
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.