Created
July 13, 2018 14:07
-
-
Save vexx32/09ab9e6d24073aa1d5517c8734a79a85 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$TriggerParams = @{ | |
Daily = $true | |
At = '12am' | |
ErrorAction = 'Stop' | |
} | |
$SettingsParams = @{ | |
ExecutionTimeLimit = [TimeSpan]::FromHours(2) | |
ErrorAction = 'Stop' | |
} | |
$TaskParams = @{ | |
Action = $Action | |
Trigger = New-ScheduledTaskTrigger @TriggerParams | |
Settings = New-ScheduledTaskSettingsSet @SettingsParams | |
ErorAction = 'Stop' | |
} | |
$Task = New-ScheduledTask @TaskParams | |
$RegisterParams = @{ | |
TaskName = $TaskName | |
InputObject = $Task | |
User = $SchedTaskCredUser | |
Password = $SchedTaskCredPwd | |
ErrorAction = 'Stop' | |
} | |
Register-ScheduledTask @RegisterParams | |
$Task = Get-ScheduledTask -TaskName $TaskName | |
$Task.Triggers.Repetition.Duration = "P1D" | |
$Task.Triggers.Repetition.Interval = "PT2M" | |
$Task | Set-ScheduledTask -User $SchedTaskCredUser -Password $SchedTaskCredPwd |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment