Skip to content

Instantly share code, notes, and snippets.

@PlagueHO
Created December 16, 2017 20:34
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/c04396780617eb85b41652e5ec8a11dc to your computer and use it in GitHub Desktop.
Save PlagueHO/c04396780617eb85b41652e5ec8a11dc to your computer and use it in GitHub Desktop.
Create a new scheduled task with no execution time limit on any version on Windows Server 2012 R2 and Windows Server 2016
$trigger = New-ScheduledTaskTrigger -Once -At '13:00:00'
$action = New-ScheduledTaskAction -Execute 'powershell.exe'
$settingsSet = New-ScheduledTaskSettingsSet
# Set the Execution Time Limit to unlimited on all versions of Windows Server
$settingsSet.ExecutionTimeLimit = 'PT0S'
$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