Link to home
Start Free TrialLog in
Avatar of samiam41
samiam41Flag for United States of America

asked on

insert code to prompt for OU to audit

Hey experts.  Here is the code I am using to dump out the users in all the groups for a particular OU.

@echo off
cls

for /f "tokens=*" %%a in ('dsquery group "OU=x,DC=y" ^|sort') do (call :oumembers %%a)

exit /b

:oumembers
set ougroup=%1
echo %ougroup% >>ou-group-members.csv
::pause
for /f "tokens=*" %%b in ('dsget group %ougroup% -members ^|sort') do (call :usersamid %%b)
goto :eof

:usersamid
set userid=%1
for /f "tokens=*" %%c in ('dsquery user %userid% -o samid') do echo ,%%c >>ou-group-members.csv
goto :eof

Open in new window


I would like to have the script prompt for what OU to audit.  How can I do this?

Thanks Experts!
ASKER CERTIFIED SOLUTION
Avatar of Bill Prew
Bill Prew

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
To get a prompt, use
set /p ou=Please enter OU to dump 

Open in new window

This sets %ou% .
Avatar of samiam41

ASKER

Clean and implemented it already.

Thank you for your help!

Qlemo, he got there first.  Hope you understand.
A new question.  Thanks for your help if you have time.

https://www.experts-exchange.com/questions/28602795/clean-up-output-in-log-file.html