Try using PowerShell's Set-ScheduledTask. You can enumerate the tasks that run under the service account, then update each task's Principal with the account name and its new password. For remote computers, use Invoke-Command so the change is made locally on each target machine.
For example, the basic operation is Set-ScheduledTask -TaskName "TaskName" -User "DOMAIN\ServiceAccount" -Password $NewPassword. For multiple remote machines, you can loop through the computer names with Invoke-Command and perform the update on each machine.
For a large environment don't hard-code the password in the script. Store the new credential securely (for example, retrieve it from a password-management system or prompt for it as a SecureString) and have the script update all affected tasks immediately after the service account password is rotated.
Note that Windows does not automatically propagate a service-account password change to scheduled tasks that have that account's password stored in their task definition.
$Credential = Get-Credential "DOMAIN\ServiceAccount"
$Computers = @(
"SERVER01",
"SERVER02",
"SERVER03"
)
$TaskNames = @(
"\MyTask1",
"\MyTask2",
"\MyTask3"
)
foreach ($Computer in $Computers) {
Invoke-Command -ComputerName $Computer -ScriptBlock {
param($TaskNames, $UserName, $Password)
foreach ($TaskName in $TaskNames) {
Set-ScheduledTask `
-TaskName $TaskName `
-User $UserName `
-Password $Password
}
} -ArgumentList `
$TaskNames,
$Credential.UserName,
$Credential.GetNetworkCredential().Password
}
If the above response helps answer your question, remember to "Accept Answer" so that others in the community facing similar issues can easily find the solution. Your contribution is highly appreciated.
hth
Marcinpro