Pwd Change

  • I want to automate the service account password change on all the servers. Any body has any experience on this.

    Shas3

  • I would very much like to dig into finding a solution for this, but not enough time today.  However, where I would start is by looking into wmi scripting and see if that is a mechanism that would have what is needed to do this. 

    The "Scripting Guys" have some great content available on wmi scripting.  Take a look at

    http://www.microsoft.com/technet/community/columns/scripts/sgwho.mspx

  • I don't have a complete solution for you, but here are bits and pieces to help you along the way:

    Services

    The Windows 2000 Resource Kit utility sc.exe can be used to change the user credentials for services on other machines.

    Scheduled Tasks (don't forget about these as well!)

    A tool that comes with Windows 2003, schtasks.exe, can be used to query all the scheduled tasks that need to be changed and make the changes to them.  It works on all jobs that are in Task Scheduler on Windows 2000 and 2003.  It won’t work with any AT scheduled jobs or Windows NT Task Scheduler jobs.  These will need to be done manually

    I have pasted a WMI script to change the password for a particular machine below (we actually use sc.exe above, but this would work as well).  I wish I could give a link to the original poster, but can't find it right now.  All I know is that it was "oj":

    '===================================================================

    'Usage:

    ' Cscript //nologo changesqlacct.vbs NewAcct NewPass oServerName - (console echo)

    ' Wscript //nologo changesqlacct.vbs NewAcct NewPass oServerName - (msgbox echo)

    '===================================================================

    Main()

    sub Main()

    Dim Args

    Dim oServerName

    Dim oServices, oService

    Dim iResult

    oServerName = "."

    NewAcct = ".\LocalSystem"

    NewPass = ""

    Set Args = Wscript.Arguments

    Select Case Args.Count

    Case 3

    NewAcct = Args(0)

    NewPass = Args(1)

    oServerName = Args(2)

    Case 2

    NewAcct = Args(0)

    NewPass = Args(1)

    End Select

    ' LIKE is only good with winxp or win2k3

    'sql = "SELECT * FROM Win32_Service WHERE Name LIKE '%sql%'"

    sql = "SELECT * FROM Win32_Service"

    Set oServices = GetObject("winmgmts:{impersonationLevel=impersonate}!//" & _

    oServerName & _

    "/root/cimv2").ExecQuery(sql,,48)

    For Each oService In oServices

    If Instr(oService.Name,"SQL")>0 Then

    Wscript.Echo "...changing acct/pass for " & oService.Name

    Wscript.Echo " Current: [" & oService.StartName & "]"

    iResult = oService.Change(,,,,,,NewAcct,NewPass)

    If iResult = 0 Then

    Wscript.Echo " ...successful changed to [" & NewAcct & "]." &

    vbCRLF

    Else

    Wscript.Echo " ...failed." & vbCRLF

    End If

    End If

    Next

    Set Args = nothing

    Set o_Servives = Nothing

    end sub

  • Thanks for the reply. With with windows resource kit we can do the following one

    TO start

    SC \\Servername Start Service_Name

    SC \\Servername Stop Service_Name

    To Change the password

    C \\Servername Config Service_Name Password = <Password>

    I am able to stop/start the service but it seems there is a syntax problem changing the passoword.

     

     

    Shas3

  • Try something like this:

    sc \\Servername config "SQLSERVERAGENT" password= <new password> >> c:\sc.txt

    Replacing <new password> with your new password.  That is, perhaps you missed the quotes around the service name?

  • I guess you don't need to include the service name in the quotes. I am able to stop/start the service without quotes

    Shas3

  • ok, I'm confused though, are you encountering an error when trying to change the password or not?

Viewing 7 posts - 1 through 7 (of 7 total)

You must be logged in to reply to this topic. Login to reply