popunder new

https://www.blogger.com/blog/posts/1739890295310631346

Wednesday, December 12, 2012

List members of all local groups on a list of computers vbs script

Here is a script that I use to list members of all local groups on a list of computers. It takes a list of computer names and checks the group members on each one then writes the results to a second file. Change the file paths in lines 6,18 and 33 to match your environment. When its complete it will open the text file with the enumerated computers.

 Const ForAppending = 8  
Const ForReading = 1
ServerCount = 0
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objTextFile = objFSO.OpenTextFile _
("c:\scripts\serverlist.txt", ForReading)
Do Until objTextFile.AtEndOfStream
strNextLine = objTextFile.Readline
strComputer = strNextLine
'WScript.Echo "Processing " & strComputer
ProcessGroups
ServerCount = ServerCount + 1
Loop
'WScript.Echo "Computers Processed " & ServerCount
'WScript.Quit
Sub ProcessGroups
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objLogFile = objFSO.OpenTextFile("c:\scripts\GroupInfo.txt", _
ForAppending, True)
objLogFile.writeline " "
objLogFile.writeline "***************** " & strComputer & " *****************"
Set colGroups = GetObject("WinNT://" & strComputer & "")
colGroups.Filter = Array("group")
For Each objGroup In colGroups
objLogFile.writeline objGroup.Name
For Each objUser in objGroup.Members
objLogFile.writeline vbTab & objUser.Name
Next
Next
objLogFile.Close
End Sub
Set WshShell = WScript.CreateObject("WScript.Shell")
WshShell.Run "C:\scripts\GroupInfo.txt"