Reputation: 197
Does anyone know how to update the Arguments of a Scheduled Task Action using PowerShell?
Here is how I have been told to update the Action, thanks to @Richard 's answer in another question.
$Action = New-ScheduledTaskAction -Execute "PowerShell.exe"
Set-ScheduledTask -TaskName "YourTaskName" -Action $Action
What do I need to add to this so I can also change the Argument and I suppose whilst we are here, the Start In option as well?
Upvotes: 7
Views: 17249
Reputation: 7000
Use the -Argument
parameters to add an argument string to an action. And use the -WorkingDirectory
parameter to add a Start In
option.
$Action = New-ScheduledTaskAction -Execute "PowerShell.exe" -Argument 'Arg1 Arg2' -WorkingDirectory "C:\StartInThisFolder\"
Upvotes: 7