VBScript - Reporting Contents Under Construction
Contents:
![bar1](web_images/darkgraybar.bmp)
![bar1](web_images/lightgraybar.bmp)
∆ Enumerating Local Admin Members
![bar1](web_images/darkgraybar.bmp)
On Error Resume Next Const ForWriting = 2 ' Variable for admin group name, modify this ' variable if the administrators account has ' been renamed. strAdminGroup = "Administrators" ' Format date/time stamp for output file strTimeDate = Year(Date) & "-" & Month(Date) & _ "-" & Day(Date) & "~~" & Hour(Time) & "-" & _ Minute(Time) ' Output file name and path strLogFile = "C:\adminaccounts-" & strTimeDate & _ ".txt"
'Create Log File Set objFSO = CreateObject("Scripting.FileSystemObject") Set objFile = objFSO.OpenTextFile (strLogFile, _ ForWriting, True)
' Connect to domain and collect computer accounts Const ADS_SCOPE_SUBTREE = 2 Set objConnection = CreateObject("ADODB.Connection") Set objCommand = CreateObject("ADODB.Command") objConnection.Provider = "ADsDSOObject" objConnection.Open "Active Directory Provider" Set objCommand.ActiveConnection = objConnection set objRootDSE = GetObject("LDAP://RootDSE") objCommand.CommandText = _ "SELECT Name, Location FROM 'LDAP://" & _ objRootDSE.Get("defaultNamingContext") & "'" _ & "WHERE objectClass='computer'" objCommand.Properties("Page Size") = 1000 objCommand.Properties("Timeout") = 30 objCommand.Properties("Searchscope") = ADS_SCOPE_SUBTREE objCommand.Properties("Cache Results") = False Set objRecordSet = objCommand.Execute objRecordSet.MoveFirst
' Output domain computer accounts, connect to each ' computer, and enumerate admin account members Do Until objRecordSet.EOF strComputer = objRecordSet.Fields("Name").Value objFile.WriteLine "System: " & strComputer Set objGroup = GetObject("WinNT://" & strComputer & _ "/" & strAdminGroup) If Err <> 0 Then objFile.Writeline("*** System Unreachable ***") Err.Clear Else For Each member In objGroup.Members objFile.WriteLine member.Name Next End If objRecordSet.MoveNext objfile.writeline() Loop
![bar1](web_images/darkgraybar.bmp) ∆
![bar1](web_images/lightgraybar.bmp)
|
..About
..I'm a Desktop Admin ..Living and loving life ........................................
..Author ....
|