?
Solved

Script to find all details from ADS

Posted on 2007-07-20
1
Medium Priority
?
201 Views
Last Modified: 2010-03-05
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
0
Comment
Question by:bsharath
1 Comment
 
LVL 26

Accepted Solution

by:
Farhan Kazi earned 2000 total points
ID: 19533347
:: ===============
:: 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

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Many admins will agree: WSUS is is a nice invention but using it on the client side when updating a newly installed computer is still time consuming as you have to do several reboots and furthermore, the procedure of installing updates, rebooting an…
When you upgrade from Windows 8 to 8.1 or to Windows 10 or if you are like me you are on the Insider Program you may find yourself with many 450MB recovery partitions.  With a traditional disk that may not be a problem but with relatively smaller SS…
With the advent of Windows 10, Microsoft is pushing a Get Windows 10 icon into the notification area (system tray) of qualifying computers. There are many reasons for wanting to remove this icon. This two-part Experts Exchange video Micro Tutorial s…
With the advent of Windows 10, Microsoft is pushing a Get Windows 10 icon into the notification area (system tray) of qualifying computers. There are many reasons for wanting to remove this icon. This two-part Experts Exchange video Micro Tutorial s…
Suggested Courses

850 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question