Results 1 to 4 of 4
  1. #1
    Join Date
    Oct 2003
    Posts
    93

    Unanswered: Scriopt to list SQL Server 2005 Service Accounts

    I have around 100 SQL Server 2005 in Production. Is there any vb script available which can take the list of servers as input and provide the details of the accounts under which SQL Server 2005 Services are running ?

    Basically I need to produce a report to confirm that no SQL server Service is using Local System Account.

    your help will be really appreciated.

  2. #2
    Join Date
    Dec 2002
    Posts
    1,245
    Quote Originally Posted by mgupta
    I have around 100 SQL Server 2005 in Production. Is there any vb script available which can take the list of servers as input and provide the details of the accounts under which SQL Server 2005 Services are running ?

    Basically I need to produce a report to confirm that no SQL server Service is using Local System Account.

    your help will be really appreciated.
    You can use WMI to query the services object and pull back the LOGON_AS property. I don't have a sample handy, but if you google WMI and Services and VBSCript, I'm sure you;ll come up with something. I'll try to check back on Monday; if no one has posted anything by then, I will try to post a sample.

    You should be aware that VBScript is being supplanted by PowerShell and other utilities. I know I am still addicted to VBS, but there are other tools out there.

    Regards,

    hmscott
    Have you hugged your backup today?

  3. #3
    Join Date
    Oct 2003
    Posts
    93
    Hi,
    Can you please post a sample ?

  4. #4
    Join Date
    Dec 2002
    Posts
    1,245
    Quote Originally Posted by mgupta
    Hi,
    Can you please post a sample ?
    Code:
    Dim sComputer
    Dim sInstance
    Dim sServiceName 
    Dim sServiceAccount
    
    If InStr(sInstance, "\") > 0 Then
       sServiceName = Right(sInstance, Len(sInstance) - InStr(sInstance,"\"))
    Else
       sServiceName = sInstance
    End if
    
    Set oWMIService = GetObject("winmgmts:{impersonationLevel=impersonate,(Security)}!\\" & sFQDN & "\root\cimv2")
    Set oItems = oWMIService.ExecQuery("SELECT * FROM Win32_Service WHERE Name = '" & sServiceName & "'",,48)
    
    For Each oItem in oItems
        sServiceAccount = oItem.StartName
    Next
    sComputer: Name of the target computer
    sInstance: Name of your SQL Instance (including "\" if named instance)
    sServiceName: Derived at runtime
    sServiceAccount: Derived at runtime, this is the startup account

    There are other items which may be of interest to you in the Win32_Service object:

    oItem.Status: Status of service
    oItem.State: State of Service
    oItem.StartMode: Startup type (auto, manual, disabled)

    I have this routine ecapsulated in a function which updates a database. I haven't shown any output routine for this -- so much of that is up to what you want do.

    Also, I have not shown where to pull the list of servers and instances from. that can be done from a spreadsheet, a text file or a database. How you do that is up to you.

    Regards,

    hmscott
    Have you hugged your backup today?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •