Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

script that can output service accounts running on multiple servers

Status
Not open for further replies.
Sep 7, 2010
6
0
0
US
Hello there-

Am looking to obtain an output file (hopefully something legible in excel if possible) based a a script that would be able to give me all the various service accounts running on over 100 Windows servers.

I am trying to create a report thru Hyena but it's not exactly what I am looking for.

I just need to execute the script where it might pull in all these servers from 1 domain (from a file if the servers are on a list) and extract the various accounts that are running on them.

If there is anything out there "canned" or code I could use please let me know....

thanks you for any support on this
SGT
 
You can use this to find none default service accounts on local computer, change strComputer and you are on a remote computer......

Code:
Const HKEY_LOCAL_MACHINE   = &H80000002
strComputer                = "."
strKeyPath                 = "SYSTEM\CurrentControlSet\services"
strSvcAcc		   = "ObjectName"
strSVCName		   = "DisplayName"

on error resume next

'Oppretter objekter
Set oReg=GetObject("winmgmts:" & _
          "{impersonationLevel=impersonate}!\\" & _
          strComputer & "\root\default:StdRegProv")


oReg.EnumKey HKEY_LOCAL_MACHINE, strKeyPath, arrSubKeys

'Loop all subkey
For Each subkey In arrSubKeys
	UpdateKeyPath = strKeyPath & "\" & subkey
	strSVCNameValue = "LOCALSERVICE"
	oReg.GetStringValue HKEY_LOCAL_MACHINE,UpdateKeyPath,strSVCName,strSVCNameValue
	oReg.GetStringValue HKEY_LOCAL_MACHINE,UpdateKeyPath,strSvcAcc,strSvcAccValue

    If (Err.Number = 0) And InStr(UCase(strSvcAccValue), "LOCALSERVICE") = 0 _
					And InStr(UCase(strSvcAccValue), "LOCALSYSTEM") = 0 _
					And InStr(UCase(strSvcAccValue), "NETWORKSERVICE") = 0 _
					Then
			Wscript.echo strSvcAccValue & vbTab & strSVCNameValue & vbTab & strComputer 
    Else
        Err.Clear
    End If
Next

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top