Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save PlagueHO/15120718e869c0f5f281e43f378bc5b0 to your computer and use it in GitHub Desktop.
Save PlagueHO/15120718e869c0f5f281e43f378bc5b0 to your computer and use it in GitHub Desktop.
Create a new scheduled task with no execution time limit on Windows Server 2016
$trigger = New-ScheduledTaskTrigger -Once -At '13:00:00'
$action = New-ScheduledTaskAction -Execute 'powershell.exe'
# Set the Execution Time Limit to unlimited on Windows Server 2016
$settingsSet = New-ScheduledTaskSettingsSet -ExecutionTimeLimit '00:00:00'
$task = New-ScheduledTask -Trigger $trigger -Action $action -Settings $settingsSet
Register-ScheduledTask -TaskName 'MyTask' -InputObject $task
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment