Re: service account expiring passwords
From: Dan Guzman (guzmanda_at_nospam-online.sbcglobal.net)
Date: 09/24/04
- Next message: Ed Johnson: "managing msde with nt authentication"
- Previous message: Hari Prasad: "RE: Database Memory"
- In reply to: jason: "service account expiring passwords"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] [ attachment ]
Date: Thu, 23 Sep 2004 21:28:27 -0500
Below is a VBScript that uses WMI to change the password for the specified
account for all services on the specified servers. Personally, I assign a
strong password and set the policy to never expire.
Option Explicit
Dim ServerName, Messages
' *** specify Windows account and new password here ***
Const StartName = "MyDomain\MyAccount" 'Windows service account name
Const NewPassword = "MyPassword"
' *** call for each server
Call ChangeServerServicePasswords("MyServer1")
Call ChangeServerServicePasswords("MyServer2")
WScript.Echo Messages
Sub ChangeServerServicePasswords(ServerName)
Dim SQL, oWin32_Services, oWin32_Service
'select all services running under this account
SQL = "SELECT * FROM Win32_Service WHERE StartName = '" & _
Replace(StartName, "\", "\\") & "'"
Set oWin32_Services = _
GetObject("winmgmts:{impersonationLevel=impersonate}!//" & _
ServerName & _
"/root/cimv2").ExecQuery(SQL, , 48)
For Each oWin32_Service In oWin32_Services
Call ChangeServicePassword(oWin32_Service)
Next
End Sub
Sub ChangeServicePassword(oWin32_Service)
Dim intResult
intResult = oWin32_Service.Change( , , , , , , , NewPassword)
If intResult = 0 Then
Messages = Messages & oWin32_Service.SystemName & _
" " & _
oWin32_Service.Caption & _
" service account password changed for account " & _
oWin32_Service.StartName & vbcrlf
Else
Messages = Messages & oWin32_Service.SystemName & _
" " & _
oWin32_Service.Caption & _
" service account password change failed for account " & _
oWin32_Service.StartName & _
". Win32_Service.Change result is " & _
CStr(intResult) & vbcrlf
End If
End Sub
-- Hope this helps. Dan Guzman SQL Server MVP "jason" <jason@discussions.microsoft.com> wrote in message news:CFFC65B4-3625-4E83-9470-741166CE67D8@microsoft.com... >I want to using a windows AD account to run the sql server and agent >services > that has an expiring password. Issue is that when that passowrd expires > and > then the servers is rebooted...the sql server service won't start. > > any ideas on how i can deal with this situation in a secure fashion, but > without manual intervetion?
- Next message: Ed Johnson: "managing msde with nt authentication"
- Previous message: Hari Prasad: "RE: Database Memory"
- In reply to: jason: "service account expiring passwords"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] [ attachment ]
Relevant Pages
|