Security Basics mailing list archives
RE: Local Administrators
From: Joey Peloquin <jpelo1 () jcpenney com>
Date: Tue, 30 Dec 2003 20:31:51 -0600
John,
Here's something to output a txt file in the format:
Machine_name
---User
---User
---User
It reads and writes input and output from its current directory. There is
pretty much no error checking, but it does confirm the machine is up first.
Specify the group to enumerate in the function, EnumServer(); currently is
Administrators.
In case you don't know, copy and paste the text into notepad, save the file
with a '.vbs' extension, and run it from the command line with 'cscript':
cscript EnumGroupUsers.vbs
Works for the ~250 machines I'm responsible for ...
Joey Peloquin
=-- Begin Script -----------------------
dim strQuery, strServer, strGroup
dim oGroup, oWSH, oFSO, oLogfile, oInputFile
dim blnServerUp, aServers, i, Group, Member
Set oWSH = CreateObject("Wscript.Shell")
Set oFSO = CreateObject("Scripting.FileSystemObject")
Set oLogFile = oFSO.OpenTextFile("output.log", 8, True)
Set oInputFile = oFSO.OpenTextFile("servers.txt", 1)
strInput = oInputFile.ReadAll()
aServers = Split(strInput, vbCrLf)
oInputFile.Close
Set oInputFile = Nothing
' Main Loop
Trace "----------------------------------------------------------------"
Trace "EnumGroupUsers.vbs started: " & Date & " -- " & Time
Trace "----------------------------------------------------------------"
For i = 0 to UBound(aServers)
If aServers(i) <> "" Then
strServer = aServers(i) ' Retrieve Server Name
Call ServerUp(strServer) ' Check to see if server is up
If blnServerUp = True Then
Trace strServer
Call EnumServer(strServer)
Else
Trace strServer & vbTab & "Offline"
End If
End If
Next
Trace "----------------------------------------------------------------"
Trace "Script Completed at: " & Time
Trace "----------------------------------------------------------------"
oWSH.Run "notepad.exe output.log"
Set oGroup = Nothing
Set oLogFile = Nothing
Set oFSO = Nothing
Set oWSH = Nothing
Wscript.Quit
'------------------= Functions and SubRoutines =-------------------
'------------------------------------------------------------------
Function EnumServer(Server)
strGroup = "Administrators"
Set oGroup = GetObject("WinNT://" & strServer & "/" & strGroup & ",group")
For each Member in oGroup.Members
'Trace strServer & vbTab & vbCrLf & _
Trace "---" & Member.Name
Next
End Function
Sub ServerUp(Server)
Err.Clear
blnServerUp = True ' Make an assumption
If oFSO.DriveExists("\\" & Server & "\" & "ADMIN$") = False Then
blnServerUp = False
Else
If Err.Number <> 0 Then
blnServerUp = False
End If
End If
End Sub
' Logging Sub Routine
Sub Trace(LogInfo)
oLogFile.WriteLine LogInfo
End Sub
=-- End Script -----------------------
[snip]
The information transmitted is intended only for the person or entity to which it is addressed and may contain confidential and/or privileged material. If the reader of this message is not the intended recipient, you are hereby notified that your access is unauthorized, and any review, dissemination, distribution or copying of this message including any attachments is strictly prohibited. If you are not the intended recipient, please contact the sender and delete the material from any computer.
--------------------------------------------------------------------------- ----------------------------------------------------------------------------
Current thread:
- Local Administrators Van Meter, John (Dec 30)
- Re: Local Administrators Administrator (Dec 31)
- RE: Local Administrators Simon and Sara Zuckerbraun (Dec 31)
- <Possible follow-ups>
- RE: Local Administrators Jacob McMaster (Dec 30)
- RE: Local Administrators Van Meter, John (Dec 30)
- RE: Local Administrators Joey Peloquin (Dec 31)
- Re: Local Administrators Anthony Smith (Dec 31)
- Re: Local Administrators Ansgar -59cobalt- Wiechers (Dec 31)
- Re: Local Administrators bo . berlas (Dec 31)
- FW: Local Administrators Boyer, G. T. IT2 ISSM Office (Dec 31)
