Created
September 9, 2019 12:26
-
-
Save johnmmoss/efc14b6ea851fb8c3b98643d53204e1e to your computer and use it in GitHub Desktop.
Example script to install a scheduled task for a console application
This file contains hidden or 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
Param( | |
$userAccount = "NT AUTHORITY\SYSTEM", | |
$exePath = "C:\Code\SampleTaskConsole\bin\Debug\SampleTaskConsole.exe", | |
$taskName = "ScormCloudReporting" | |
) | |
Unregister-ScheduledTask -TaskName $taskName -Confirm:$false -ErrorAction SilentlyContinue | |
$action = New-ScheduledTaskAction -Execute $exePath | |
$trigger = New-ScheduledTaskTrigger -Daily -At 1am | |
$principal = New-ScheduledTaskPrincipal -UserID $userAccount -LogonType ServiceAccount -RunLevel Highest | |
Register-ScheduledTask -Action $action -Trigger $trigger -TaskName $taskName -Description $taskName -Principal $principal |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment