Retrieve these details from ADS

Posted on 2007-08-12
Last Modified: 2008-02-01

I have the emp id's in the Description box for the users.What i want is in a txt file i have all the descriptions of users.When the description is found in the users description box.I want the script to retrieve these details.

EMP ID thats the description
Phone no
Manager name

Question by:bsharath
    LVL 11

    Author Comment

    All the data to a csv file.
    LVL 70

    Expert Comment

    You will need to use CSVDE

    CSVDE -f userlist.csv  "DN, description, displayName, telephoneNumber, streetAddress, manager"

    There is a list of the LDAP fields at
    LVL 11

    Author Comment

    I get this

    C:\>CSVDE -f userlist.csv  "DN, description, displayName, telephoneNumber, stree
    tAddress, manager"
    Invalid Parameter: Bad argument 'DN, description, displayName, telephoneNumber,
    streetAddress, manager'

    CSV Directory Exchange
    LVL 26

    Accepted Solution

    Not in CSV Format

    :: ===============
    :: ===============
    :: * This script require "EmpNoList.txt" file on C: drive root from where it will pick NT Logins.
    :: * Successful run will generate two files "EmpInfoRpt.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

    IF NOT EXIST C:\EmpNoList.txt Goto ShowErr
    FOR %%R IN (C:\EmpNoList.txt) Do IF %%~zR EQU 0 Goto ShowErr
    IF EXIST C:\EmpInfoRpt.txt DEL /F /Q C:\EmpInfoRpt.txt

    FOR /F "delims=*" %%a IN ('Type C:\EmpNoList.txt') Do (
        Echo Checking %%a
          DSQuery User -Desc %%a* >C:\CNTmp.txt
          Type C:\CNTmp.txt |FIND /I "CN=" >NUL
          IF Not ErrorLevel 1 (
                SET /P UserCN=<C:\CNTmp.txt
              SET Qry=DSQuery * !UserCN! -Attr description sAMAccountName telephoneNumber streetAddress title manager
                FOR /F "skip=1 delims=*" %%i IN ('!Qry!') DO Echo %%i >>C:\EmpInfoRpt.txt
          )ELSE (Echo '%%a' User ID Not Found. >>C:\EmpInfoRpt.txt)
    Goto EndScript
    Echo "C:\EmpNoList.txt" file does not exist or file is empty!
    IF EXIST C:\CNTmp.txt DEL /F /Q C:\CNTmp.txt
    :: *** SCRIPT END ***

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Looking for New Ways to Advertise?

    Engage with tech pros in our community with native advertising, as a Vendor Expert, and more.

    Some time ago I faced the need to use a uniform folder structure that spanned across numerous sites of an enterprise to be used as a common repository for the Software packages of the Configuration Manager 2007 infrastructure. Because the procedu…
    INTRODUCTION The purpose of this document is to demonstrate the Installation and configuration of the Data Protection Manager product. Note that this demonstration was prepared on the basis of Windows OS is 2008 R2 and DPM 2010. DATA PROTECTI…
    This video Micro Tutorial explains how to clone a hard drive using a commercial software product for Windows systems called Casper from Future Systems Solutions (FSS). Cloning makes an exact, complete copy of one hard disk drive (HDD) onto another d…
    Windows 8 came with a dramatically different user interface known as Metro. Notably missing from that interface was a Start button and Start Menu. Microsoft responded to negative user feedback of the Metro interface, bringing back the Start button a…

    779 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

    Need Help in Real-Time?

    Connect with top rated Experts

    14 Experts available now in Live!

    Get 1:1 Help Now