Exporting a list of all local groups and their members of a windows machine
#1
Scooby Regular
Thread Starter
Exporting a list of all local groups and their members of a windows machine
Anyone know of a script that can do it - can't be powershell as needs to be on 2003 servers with no access to powershell.
I don't want individual lists of each group and its members as that's easily achievable in command line, I need one output file with all groups and their members preferably into csv format.
I have searched Google and can't find anything so not looking good for a successful outcome on this.
I don't want individual lists of each group and its members as that's easily achievable in command line, I need one output file with all groups and their members preferably into csv format.
I have searched Google and can't find anything so not looking good for a successful outcome on this.
#2
Scooby Regular
Join Date: Aug 2003
Location: Epsom
Posts: 5,832
Likes: 0
Received 0 Likes
on
0 Posts
net localgroup >c:\grouplist.csv will give you the localgroups
edit the file to get rid of the headers etc, then you can get each member with
for /f "tokens=1" %%i in (c:\grouplist.csv) do net localgroup %%i >> c:\members.csv
edit the file to get rid of the headers etc, then you can get each member with
for /f "tokens=1" %%i in (c:\grouplist.csv) do net localgroup %%i >> c:\members.csv
Last edited by warrenm2; 28 December 2013 at 08:02 PM.
#3
Try this VBScript, it will interrogate all the local groups on a given computer and list it's members:
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"
Create and enter the hostnames of the computers you want to interrogate in serverlist.txt.
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"
Create and enter the hostnames of the computers you want to interrogate in serverlist.txt.
Thread
Thread Starter
Forum
Replies
Last Post