samiam41
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.
I would like to have the script prompt for what OU to audit. How can I do this?
Thanks Experts!
@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
I would like to have the script prompt for what OU to audit. How can I do this?
Thanks Experts!
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Clean and implemented it already.
Thank you for your help!
Qlemo, he got there first. Hope you understand.
Thank you for your help!
Qlemo, he got there first. Hope you understand.
ASKER
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
https://www.experts-exchange.com/questions/28602795/clean-up-output-in-log-file.html
Open in new window
This sets %ou% .