-
Notifications
You must be signed in to change notification settings - Fork 26
/
schedule_usage_upload.ps1
33 lines (25 loc) · 1.5 KB
/
schedule_usage_upload.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
[CmdletBinding()]
param(
[Parameter(Mandatory = $true)]
[string] $CloudName
)
#Usage Data Upload
$action = New-ScheduledTaskAction -Execute 'Powershell' `
-Argument (".\asUsageToOMS.ps1 -CloudName '{0}'" -f $CloudName) -WorkingDirectory "C:\AZSAdminOMSInt"
$description = "Daily upload of usage data from azure stack to OMS"
$taskName = "UsageDataUpload1_$CloudName"
$trigger = New-ScheduledTaskTrigger -Daily -At 9am
$principal = New-ScheduledTaskPrincipal -UserID "NT AUTHORITY\SYSTEM"
$twoHours = New-TimeSpan -Hour 2
$settings = New-ScheduledTaskSettingsSet -ExecutionTimeLimit $twoHours
Register-ScheduledTask -Action $action -Trigger $trigger -TaskName $taskName -Principal $principal -Description $description -Settings $settings
#Operational Data Upload
$action = New-ScheduledTaskAction -Execute 'Powershell' `
-Argument (".\OpsDataToOMS.ps1 -CloudName '{0}'" -f $CloudName) -WorkingDirectory "C:\AZSAdminOMSInt"
$description = "Daily upload of operational data from azure stack to OMS"
$taskName = "OperationalDataUpload1_$CloudName"
$trigger = New-ScheduledTaskTrigger -once -at (Get-date) -RepetitionInterval (New-TimeSpan -Minutes 13) -RepetitionDuration (New-TimeSpan -Days 9999)
$principal = New-ScheduledTaskPrincipal -UserID "NT AUTHORITY\SYSTEM"
$tenMinutes = New-TimeSpan -Minute 10
$settings = New-ScheduledTaskSettingsSet -ExecutionTimeLimit $tenMinutes
Register-ScheduledTask -Action $action -Trigger $trigger -TaskName $taskName -Principal $principal -Description $description -Settings $settings