-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathCreateSchedules.ps1
36 lines (27 loc) · 1.28 KB
/
CreateSchedules.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
param (
# Name of the resource group that will contain the Automation account
[Parameter(Mandatory=$true)]
[string]$resGroupName,
# Name of the Automation account (shown in the portal)
[Parameter(Mandatory=$true)]
[string]$automationAccountName,
# Subscription Id
[Parameter(Mandatory=$true)]
[string]$subscriptionId,
# Environemnt to log in to
[Parameter(Mandatory=$false)]
[ValidateSet("AzureCloud","AzureUSGovernment")]
[string]$EnvironmentName="AzureCloud",
# How frequently (minutes) to perform DNS resolution for monitored FQDN's
[Parameter(Mandatory=$false)]
[int]$pollingInterval = 5
)
Login-AzureRmAccount -EnvironmentName $EnvironmentName
$Subscription = Select-AzureRmSubscription -SubscriptionId $SubscriptionId
$startTime = Get-date
$startTime = $startTime.AddMinutes(10)
for ($i=0; $i -lt 60; $i = $i+$pollingInterval) {
$time = $startTime.AddMinutes($i)
$schedule = New-AzureRmAutomationSchedule -AutomationAccountName $automationAccountName -ResourceGroupName $resGroupName -Name "Hourly$i" -HourInterval 1 -StartTime $time
Register-AzureRmAutomationScheduledRunbook -AutomationAccountName $automationAccountName -ResourceGroupName $resGroupName -RunbookName "MonitorFQDN" -ScheduleName $schedule.Name
}