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?
Microsoft Windows Task Scheduler can run PowerShell scripts, but to do so you will first need to specify it as an argument to PowerShell. Hopefully this article will help you automate many of your daily activities on your Windows system.
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\"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With