You are here

Automated password change of the account in the Windows Task Scheduler


Автоматизированная смена пароля учётной записи в планировщике заданий Windows

When the need arises to change the password of the service account, on behalf of which tasks are operated in the Windows Task Scheduler, especially if there are many tasks, you might want to simplify this process. In this short note, I will show you how to do it quickly and easily.

A Simple Solution for Changing the Account Password in many Scheduler Tasks

To start, here are the commands you will need:

$NewTaskCreds = Get-Credential
$comps=get-adcomputer -filter {cn -like "mx0*" -and enabled -eq "True"}
#$comps=@("comp1","comp2","comp3")
foreach ($comp in $comps){
    Get-ScheduledTask -CimSession $comp.name | Where-Object { $_.Principal.UserId -eq $NewTaskCreds.UserName } | Set-ScheduledTask -User $NewTaskCreds.UserName -Password $NewTaskCreds.GetNetworkCredential().Password
    #Get-ScheduledTask -CimSession $comp.name | Where-Object { $_.Principal.UserId -eq $user }
}

 

If you need to change the password only on a single local machine, simply remove the loop and the -CimSession parameter.

Additional Resources

The script is included in ]]>a project on GitHub]]>, which also contains a script for copying a large number of tasks to remote machines. This can be useful if you have many tasks that need to be on multiple servers.

11 9

Share the article with your friends in social networks, maybe it will be useful to them.


If the article helped you, you can >>thank the author<<