This require an elevated shell

Create Task

Syntax in powershell

$action = New-ScheduledTaskAction -Execute 'PROGRAM' 
$trigger = New-ScheduledTaskTrigger -SETTING -At TIME
Register-ScheduledTask -Action $action -Trigger $trigger -TaskPath "TASK-FOLDER" -TaskName "TASK-NAME" -Description "OPTIONAL-DESCRIPTION-TEXT" -User "Username"
  • Replace PROGRAM with the name of the program you are creating the task for
  • Replace -SETTING with the frequency, such as Daily. Replace -At TIME with a time, such as “At 7am.”
  • Replace TASK-FOLDERTASK-NAME, and OPTIONAL-DESCRIPTION-TEXT with your task information.
  • The -TaskPath is optional but helps you to identify your created tasks.
  • The -User is optional (mandatory if you run this command from NT AUTHORITY\SYSTEM) allow you to specify the user who will run the task, for example “System”, see : https://stackoverflow.com/questions/2000674/powershell-create-scheduled-task-to-run-as-local-system-service

You can use Once, Daily, Weekly, or Monthly for the frequency. The time can be in 12 or 24-hour format. If you are using the Weekly frequency, you can also add -DaysOfWeek, and then the day. You can also use -DaysInterval to control the frequency. For example, -DaysInterval 3, will run the task every three days.

Example

$action = New-ScheduledTaskAction -Execute 'C:\Users\talion\AppData\Roaming\jkr.exe' 
$trigger = New-ScheduledTaskTrigger -Daily -At 8am
Register-ScheduledTask -Action $action -Trigger $trigger "My Tasks" -TaskName "joker" -Description "persistent malware" -User "System"

Read Task

Get-ScheduledTask -TaskName "TASK-NAME"

Update Task

$trigger = New-ScheduledTaskTrigger -SETTING -At TIME
$action = New-ScheduledTaskAction -Execute 'PROGRAM'
Set-ScheduledTask -Trigger $trigger -Action $action -TaskPath "TASK-FOLDER" -TaskName "TASK-NAME"

Delete Task

Unregister-ScheduledTask -TaskName "TASK-NAME" -Confirm:$false

Source