VBS Script to identify Local Admins only on SERVERS
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???

Software/Hardware used:
ASKED: June 26, 2008  12:36 AM
UPDATED: June 27, 2008  8:35 AM

Answer Wiki:
Hello Eigenstein, you can do this by using the following script example: <pre> 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 </pre> The script above read server names from a <i>c:test.txt </i> file and then uses the subroutine EnumLocalAdmins to enumerate the local administrator's members. Bye Don't forget to visit my blog:<a href="http://itknowledgeexchange.techtarget.com/it-support/"> If it has a plug, it's IT stuff!!</a>
Last Wiki Answer Submitted:  June 27, 2008  8:35 am  by  alessandro.panzetta   9,680 pts.
All Answer Wiki Contributors:  alessandro.panzetta   9,680 pts.
To see all answers submitted to the Answer Wiki: View Answer History.


Discuss This Question:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _


 

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.

 6,565 pts.