Question:
I want to update the password of all the services running under one account on multiple servers using powershell. i tried Get-process, Get-WMIObject cmdlets, but these two commands don’t have serviceaccount usage. is there a way to update password of all the services running with an account by passing service account,password as parameters to the script.
Answer:
To get list of services using a particular account you can do:
1 2 |
Get-WmiObject "win32_service" -Filter "StartName='domain\\user'" |
To change the password for these, you can do:
1 2 3 |
Get-WmiObject "win32_service" -Filter "StartName='domain\\user'" | %{$_.StopService();$_.Change($null,$null,$null,$null,$null,$null,$null,"blah");} |
From here: http://www.send4help.net/change-remote-windows-service-credentials-password-powershel-495