Page 1 of 1 1
Topic Options
#186681 - 2008-04-03 12:59 PM Service Account Amendments
DJYeo Offline
Fresh Scripter

Registered: 2008-04-03
Posts: 5
I need a script to query all the services on a server and amend any that are running under a specific domain account. We are about to rename the NETBIOS name on our domain from X to Y. I need to amend the domain from X to Y of the service account but not the username as this is already set correctly.

Any Ideas????

#186686 - 2008-04-03 02:28 PM Re: Service Account Amendments [Re: DJYeo]
Mart Moderator Offline
KiX Supporter

Registered: 2002-03-27
Posts: 4642
Loc: The Netherlands
Can't test right now but my guess is that the fnWMIService() UDF will do what you want.

- Chuck Norris once sold ebay to ebay on ebay.

#186687 - 2008-04-03 03:49 PM Re: Service Account Amendments [Re: Mart]
Glenn Barnas Administrator Offline
KiX Supporter

Registered: 2003-01-28
Posts: 4290
Loc: New Jersey
You can also try this one which also uses WMI but requires a bit less coding on your part to set up and query.

You can use
$aServices = WMISvcMgr('list')

to get a list of services, then enumerate each service to find the ones to change
; define a new array, but only set what needs to change - the userID/password
Dim $aNewSvcData[9]
$aNewSvcData[8] = 'NewDomain\NewAccount'
$aNewSvcData[9] = 'NewPassword'
; Enumerate the array of services
For Each $Service in $Services
  $aSvcData = WMISvcMgr('query', $Service)
  ; If the service account contains the old user ID, update it
  If InStr($aSvcData[8], 'OldUserID')
    $ = WMISvcMgr('query', $Service, $aNewSvcData)
    ; Don't forget to check for errors!


PS - the latest version of this UDF is on the resources section of my web site. I don't think it changed, though. I never found time to implement the Create function.
Actually I am a Rocket Scientist! \:D

#186693 - 2008-04-03 05:29 PM Re: Service Account Amendments [Re: Glenn Barnas]
DJYeo Offline
Fresh Scripter

Registered: 2008-04-03
Posts: 5
MAny thanks for the above but unfortunatley its well beyond my KIX knowledge, all is need is the below: -

Old Service Account - Domain01\SQLServer.svc

to change to

New Service Account - Domain02\SQLServer.svc

The password can remain the same, just need to query all srvices and amend the domain part.

Page 1 of 1 1

Moderator:  Glenn Barnas, NTDOC, Arend_, Jochen, Radimus, Allen, ShaneEP, Mart 
Hop to:
Shout Box

Who's Online
1 registered (Lonkero) and 175 anonymous users online.
Newest Members
gkustra, emnipetro, Hirze, thequeen, ameliaryan
17642 Registered Users

Generated in 0.03 seconds in which 0.011 seconds were spent on a total of 13 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google: