DJYeo
(Fresh Scripter)
2008-04-03 12:59 PM
Service Account Amendments

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????


Mart
(KiX Supporter)
2008-04-03 02:28 PM
Re: Service Account Amendments

Can't test right now but my guess is that the fnWMIService() UDF will do what you want.

http://www.kixtart.org/forums/ubbthreads.php?ubb=showflat&Number=84031


Glenn BarnasAdministrator
(KiX Supporter)
2008-04-03 03:49 PM
Re: Service Account Amendments

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
 Code:
$aServices = WMISvcMgr('list')

to get a list of services, then enumerate each service to find the ones to change
 Code:
; 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!
  EndIF
Next

Glenn

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.


DJYeo
(Fresh Scripter)
2008-04-03 05:29 PM
Re: Service Account Amendments

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.