How can I modify an existing scheduled task using Powershell?

Solution 1:

The RegisterTask method has an update flag that you would use. Something like this:

# Update the action with the new working directory and executable
$action.WorkingDirectory = $exe.DirectoryName
$action.Path = $exe.FullName

#Update Task
$taskFolder.RegisterTask($task.Name, $task.Definition, 4, "<username>", "<password>", 1, $null)

See the msdn article for details on each parameter.