Script to find all details from ADS

Hi,

I need a script which pops a box and when i enter the description name in which i have the emp id's of a user.When i enter the emp id it has to generate a file with the username,nt login,email id and full name.

Regards
Sharath
LVL 11
bsharathAsked:
Who is Participating?
 
Farhan KaziConnect With a Mentor Systems EngineerCommented:
:: ===============
:: READ THIS FIRST
:: ===============
:: * This script will ask for Emp # and will extract all information from Active Directory
:: * Successful run will generate "AD_EmpNo.txt" file on C: drive root.
:: * Copy and paste following script in notepad and save it with any name having .bat extension.
::
:: *** SCRIPT START ***
@Echo Off
SETLOCAL EnableDelayedExpansion
SET Fields= description sAMAccountName mail name
:AskAgain
Cls
SET EmpNo=
SET /P EmpNo="Enter Employee No: [Enter to Quit]? "
IF "%EmpNo%"=="" Goto :EndScript
DSQuery User -desc "%EmpNo%*" | Find "CN=" >NUL
IF ERRORLEVEL 1 Goto :ShowErr
DSQuery * -Filter "(&(objectCategory=Person)(objectClass=User)(description="%EmpNo%*"))" -Attr %Fields% >C:\AD_%EmpNo%.txt
Echo.
Echo Information Extracted. Check C:\AD_%EmpNo%.txt file.
Echo.
Pause
Goto :AskAgain
Goto EndScript
:ShowErr
Echo.
Echo '%EmpNo%' Not Found in Active Directory
Echo.
Pause
Goto :AskAgain
:EndScript
ENDLOCAL
:: *** SCRIPT END ***    
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.