JSI Tip 9346. How can I generate a CSV file of all local group membership?

Jerold Schulman

May 12, 2005

1 Min Read
ITPro Today logo in a gray background | ITPro Today


Using only standard commands, I have scripted EnumLclGrp.bat to output local group membership.The syntax for using EnumLclGrp.bat is:

EnumLclGrp

The output is displayed on the console, but can be redirected to a file using EnumLclGrp>fileName or EnumLclGrp>>fileName.

Each line of output contains:

"Computer Name","Local Group Name","User Name"

EnumLclGrp.bat contains:

@echo offsetlocal ENABLEDELAYEDEXPANSIONfor /f "Tokens=*" %%a in ('net localgroup^|findstr /b /l /c:"*"') do ( set wrk=%%a set grp=!wrk:~1! for /f "Skip=6 Tokens=*" %%b in ('net localgroup "!grp!"^|find /I /V "The command completed successfully."') do (  @echo "%ComputerName%","!grp!","%%b" ))endlocal



Sign up for the ITPro Today newsletter
Stay on top of the IT universe with commentary, news analysis, how-to's, and tips delivered to your inbox daily.

You May Also Like