• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 321
  • Last Modified:

Retrieve these details from ADS

Hi,

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
Username
Phone no
Address
Title
Manager name

Regards
Sharath
0
bsharath
Asked:
bsharath
  • 2
1 Solution
 
bsharathAuthor Commented:
All the data to a csv file.
0
 
KCTSCommented:
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 http://www.computerperformance.co.uk/Logon/LDAP_attributes_active_directory.htm
0
 
bsharathAuthor Commented:
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
0
 
Farhan KaziSystems EngineerCommented:
Not in CSV Format

:: ===============
:: READ THIS FIRST
:: ===============
:: * 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
:ShowErr
Echo "C:\EmpNoList.txt" file does not exist or file is empty!
:EndScript
IF EXIST C:\CNTmp.txt DEL /F /Q C:\CNTmp.txt
ENDLOCAL
:: *** SCRIPT END ***
0

Featured Post

Prep for the ITIL® Foundation Certification Exam

December’s Course of the Month is now available! Enroll to learn ITIL® Foundation best practices for delivering IT services effectively and efficiently.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now