Notices
Computer & Technology Related Post here for help and discussion of computing and related technology. Internet, TVs, phones, consoles, computers, tablets and any other gadgets.

Exporting a list of all local groups and their members of a windows machine

Thread Tools
 
Search this Thread
 
Old 23 December 2013, 11:46 AM
  #1  
An0n0m0us
Scooby Regular
Thread Starter
 
An0n0m0us's Avatar
 
Join Date: Jun 2005
Location: UK
Posts: 3,597
Received 29 Likes on 16 Posts
Question 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.
Old 28 December 2013, 07:57 PM
  #2  
warrenm2
Scooby Regular
 
warrenm2's Avatar
 
Join Date: Aug 2003
Location: Epsom
Posts: 5,832
Likes: 0
Received 0 Likes on 0 Posts
Default

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

Last edited by warrenm2; 28 December 2013 at 08:02 PM.
Old 29 December 2013, 06:07 PM
  #3  
jonc
Scooby Regular
 
jonc's Avatar
 
Join Date: Apr 2002
Posts: 7,635
Likes: 0
Received 18 Likes on 13 Posts
Default

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.
Old 05 January 2014, 10:59 PM
  #4  
An0n0m0us
Scooby Regular
Thread Starter
 
An0n0m0us's Avatar
 
Join Date: Jun 2005
Location: UK
Posts: 3,597
Received 29 Likes on 16 Posts
Default

Thanks for the replies. A colleague gave me a vbs script that worked spot on. I'll compare against the above though to see how they differ.
Related Topics
Thread
Thread Starter
Forum
Replies
Last Post
JimBowen
ICE
5
02 July 2023 01:54 PM
Littleted
Computer & Technology Related
0
25 September 2015 08:44 AM



Quick Reply: Exporting a list of all local groups and their members of a windows machine



All times are GMT +1. The time now is 03:00 AM.