Question

  Asked: Jun 26 2008   0:36 AM GMT
  Asked by: Eigenstein


VBS Script to identify Local Admins only on SERVERS


Security, VBScript, Windows scripting, Scripting

I'm an auditor, and I like to know things like: are there local IDs on servers? Are those local IDs also in the administrator group?

Not only that, I need to hand this script out to various admins, so I can't specify one domain name in the script.

So, first I need to get the domain name, then identify all the servers on the domain, then pull only local user IDs and their local group membership and push it to a text file (Excel would be better, but I know what I'm asking!)

I've used:
strDomainName = InputBox("Enter Domain Name To Query")

for my other scripts, but getting the rest of the info into one script is far beyond my scripting skills. Admins in many companies would bless your efforts. I would be personally thrilled and sing your praises on my blog. How bout it, scripters???

Subscribe to Alerts! Get questions and answers delivered to your Inbox.


E-mail me updates on this question



   SUBSCRIBE

hidden modal window

Answer Wiki (Improve, edit or add to this answer)


 RATE THIS ANSWER
0
Click to Vote:
  •   0
  •  0



Hello Eigenstein,
you can do this by using the following script example:


Dim arrFileLines()
i = 0
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.OpenTextFile("C:\test.txt", 1)
Do Until objFile.AtEndOfStream
Redim Preserve arrFileLines(i)
arrFileLines(i) = objFile.ReadLine
i = i + 1
Loop
objFile.Close
For l = Lbound(arrFileLines) to UBound(arrFileLines)
EnumLocalAdmins arrFileLines(l)
Next

Sub EnumLocalAdmins(ServerName)
Set colGroups = GetObject("WinNT://" & ServerName & "")
colGroups.Filter = Array("group")
For Each objGroup In colGroups
Wscript.Echo objGroup.Name
For Each objUser in objGroup.Members
Wscript.Echo vbTab & objUser.Name
Next
Next
End Sub


The script above read server names from a c:\test.txt file and then uses the subroutine EnumLocalAdmins to enumerate the local administrator's members.

Bye

Don't forget to visit my blog: If it has a plug, it's IT stuff!!
  • AddThis Social Bookmark Button

Browse more Questions and Answers on Security, Development and Microsoft Windows.

Looking for relevant Security Whitepapers? Visit the SearchSecurity.com Research Library.


Discuss This Answer


You must be logged-in to discuss a question. Log-in/Register

BrentSheets  |   Jun 26 2008  12:55PM GMT

Eigen, hopefully fellow community blogger Jerry Lees will drop by this question. He has a blog on IT Knowledge Exchange called The VBScript Network and Systems Administrator’s Cafe and may be able to help. You may wish to post a comment on his blog if you see an applicable post.