Celeb Glow
general | March 08, 2026

Start Python script with Task Scheduler via PowerShell

With PowerShell, I want to create a new task that starts a Python script:

enter image description here

Setting it this way via the GUI Task Scheduler works, but in my PowerShell code below, I don't know how to specify the "add arguments" field:

$action = New-ScheduledTaskAction -Execute "C:\Program Files\Python\Python38\python.exe"
$trigger = New-ScheduledTaskTrigger -Daily -At 5:00am
$trigger.StartBoundary = [DateTime]::Parse($trigger.StartBoundary).ToLocalTime().ToString("s")
$settings = New-ScheduledTaskSettingsSet -ExecutionTimeLimit 0
Register-ScheduledTask -Action $action -Trigger $trigger -Settings $settings -TaskName "Full Computer Backup" -Description "Backs up computer"

What change must I make to the PowerShell code to add the argument (in this case, the path to the python script [.py file])?

1 Answer

Use the -Argument parameter with the New-ScheduledTaskAction command.

You can add the full path as the value for the -Argument parameter (e.g. -Argument "<script path value>") to add this as the value for the task's Add arguments (optional) field value.

PowerShell

$action = New-ScheduledTaskAction -Execute "C:\Program Files\Python\Python38\python.exe" -Argument "C:\Scripts\mypScript.py"
$trigger = New-ScheduledTaskTrigger -Daily -At 5:00am
$trigger.StartBoundary = [DateTime]::Parse($trigger.StartBoundary).ToLocalTime().ToString("s")
$settings = New-ScheduledTaskSettingsSet -ExecutionTimeLimit 0
Register-ScheduledTask -Action $action -Trigger $trigger -Settings $settings -TaskName "Full Computer Backup" -Description "Backs up computer"

Supporting Resources

1

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy