Powershell commands
View the current list of scheduled tasks
schtasks.exe
Help
For a full list of supported parameters
schtasks.exe /?
Create a new scheduled task
schtasks /Create /?
schtasks /Create /SC ONSTART /TN MyTaskName /TR "some command to exectute or path to a batchfile"
Run as Administrator:
schtasks /Create /SC ONSTART /TN MyTaskName /TR "some command to exectute or path to a batchfile" /RU SYSTEM
Delete scheduled task
schtasks /Delete /TN MyTaskName
Displays scheduled tasks
schtasks /Query
schtasks /Query /TN MyTaskName
Change the properties of scheduled task
schtasks /Change /?
Run scheduled task on demand
schtasks /Run /TN MyTaskName
Stop currently running scheduled task
schtasks /End
Adding a task to to the OS task scheduler
schtasks is in System32 if it's not already in your path.
schtasks can be run either on startup, timed, or as a one off execution
Full paths are needed in schtasks.
Examples
schtasks /Create /SC ONSTART /TN TimeSync /TR "w32tm /resync"
This forces a time re-sync. You could replace the /TR with a script rather than a direct command.
Triggering running of a batch file
Batch files need to be ANSI not Unicode.
Testing powershell script when run through powershell command line can have errors and still complete, but when running as script file from task scheduler can "shells out" and stop when reaching an error in the file, so ensure you include error handling if needed.
Full paths are needed in schtasks.