Change Service Credentials and More..

Ask your PowerShell-related questions, including questions on cmdlet development!
Forum rules
Do not post any licensing information in this forum.

Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
This topic is 15 years and 8 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked
User avatar
highp
Posts: 2
Last visit: Fri Jun 27, 2008 8:54 am

Change Service Credentials and More..

Post by highp »

Is it at all possible to create a powershell script that will update a local service's Log On As credentials?
I need to create a script that will do 3 things:

1) Change a local service accounts log on as credentials
2) Change a AD user accounts password
3) Restart a service on a local machine

Any help would be appreciated.
User avatar
highp
Posts: 2
Last visit: Fri Jun 27, 2008 8:54 am

Change Service Credentials and More..

Post by highp »

Is it at all possible to create a powershell script that will update a local service's Log On As credentials?
I need to create a script that will do 3 things:

1) Change a local service accounts log on as credentials
2) Change a AD user accounts password
3) Restart a service on a local machine

Any help would be appreciated.
User avatar
jhicks
Posts: 1789
Last visit: Mon Oct 19, 2015 9:21 am

Change Service Credentials and More..

Post by jhicks »

Sure. You'll need to use Get-WMIObject to change the service account. The StartName property is the service account. To change an AD user account password, the easiest solution is to use the Set-QADUser cmdlet from Quest. Otherwise you can do it using ADSI. To restart a local service use the Restart-Service cmdlet.
User avatar
jhicks
Posts: 1789
Last visit: Mon Oct 19, 2015 9:21 am

Change Service Credentials and More..

Post by jhicks »

That's what we're here for.
User avatar
jhicks
Posts: 1789
Last visit: Mon Oct 19, 2015 9:21 am

Change Service Credentials and More..

Post by jhicks »

I'm not sure I follow. You don't have access to an account but you can impersonate it? You still need to know the username and password for the impersonation so this doesn't make sense to me. All ADSI needs is a secure connection to the remote machine which you can do by mapping a drive to it using alternate credentials:net use z: server01admin$ /user:mydomainadmin P@ssw0rdCan you do something like that?
This topic is 15 years and 8 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked