Created
July 17, 2020 11:43
-
-
Save jftuga/da9558855bf3a077a8cb7077ad4bcf7c to your computer and use it in GitHub Desktop.
How to create a Scheduled Task with PowerShell
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
# This task will run once per day at 9AM, only on week days | |
$A = New-ScheduledTaskAction -Execute "c:\scripts\my_project\scheduled_task.bat" -WorkingDirectory "c:\scripts\my_project" | |
$T = New-ScheduledTaskTrigger -At 9am -Weekly -DaysofWeek Monday,Tuesday,Wednesday,Thursday,Friday | |
$P = New-ScheduledTaskPrincipal -UserId "LOCALSERVICE" -LogonType ServiceAccount | |
$S = New-ScheduledTaskSettingsSet | |
$D = New-ScheduledTask -Action $A -Principal $P -Trigger $T -Settings $S | |
Register-ScheduledTask "My Project" -InputObject $D |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment