VBS Script to identify Local Admins only on SERVERS

Tags:
Scripting
Security
VBScript
Windows 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?

Answer Wiki

Thanks. We'll let you know when a new response is added.

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!!

Discuss This Question: 1  Reply

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
  • BrentSheets
    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,925 pointsBadges:
    report

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Thanks! We'll email you when relevant content is added and updated.

Following