We help IT Professionals succeed at work.

We've partnered with Certified Experts, Carl Webster and Richard Faulkner, to bring you two Citrix podcasts. Learn about 2020 trends and get answers to your biggest Citrix questions!Listen Now

x

Script to find all details from ADS

Medium Priority
213 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
Comment
Watch Question

Systems Engineer
CERTIFIED EXPERT
Top Expert 2007
Commented:
:: ===============
:: 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 ***    

Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts
Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.