Scheduled tasks are contained in C:\Windows\System32\Tasks\ and contain XML files. While the Petri article is a good solution for Windows 8 and Windows Server 2012, that's not a complete solution. This should allow you to find the tasks with a specific command or argument, and replace those.
$computer = "localhost"
$oldCommand = "C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe"
$oldArguments = "-File `"C:\Users\Public\Scripts\oldScript.ps1`""
$newCommand = "C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe"
$newArguments = "-File `"C:\Users\Public\Scripts\newScript.ps1`""
$tasks = Get-ChildItem "\\$computer\c$\Windows\System32\Tasks\" | Where-Object {
$_.PSIsContainer -eq $false `
-and `
(([xml](Get-Content -Path $_.FullName)).Task.Actions.Exec.Command -like $oldCommand) `
-and `
(([xml](Get-Content -Path $_.FullName)).Task.Actions.Exec.Arguments -like $oldArguments)
}
$tasks | ForEach-Object {
$xml = [xml](Get-Content -Path $_.FullName)
$xml.Task.Actions.Exec.Command = $newCommand
$xml.Task.Actions.Exec.Arguments = $newArguments
$xml.Save($_.FullName)
}
Export the tasks as .xml, run a find+replace, then import the tasks. – Wutnaut – 2014-06-04T18:08:23.417
I saw that you have HUNDREDS of scheduled tasks and found out the scheduled tasks module will only let you export 1 task at a time, so you may find this resource handy, especially since you're already working in PS: http://www.petri.co.il/export-scheduled-tasks-using-powershell.htm
– Wutnaut – 2014-06-04T18:18:26.717