Need to get the description of all the nt logins or email id's in the list

Hi,

I need to get the Description of all the Nt logins or email id's in the txt file.

From the ads

regards
Sharath
LVL 11
bsharathAsked:
Who is Participating?
 
Farhan KaziSystems EngineerCommented:
:: ===============
:: READ THIS FIRST
:: ===============
:: * This script UserIDs.txt file on C: drive root, from where it will pick users SAM ID of or email address.
::      'UserIDs.txt' file should be in following format:
::      Like:
::           FKazi
::           fkazi@somedomain.com
:: * Successful run will generate "DescReport.txt" file on C: drive root.
:: * Copy and paste following script in notepad and save it with any name having .cmd extension.
::
:: *** SCRIPT START ***
@Echo Off
SETLOCAL EnableDelayedExpansion

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

FOR /F "Tokens=1" %%i IN ('Type C:\UserIDs.txt') Do (
      Echo Processing: %%i
      Echo %%i | Find "@" >NUL
      IF NOT ErrorLevel 1 (      
        SET Qry=DSQuery * DomainRoot -Filter "(&(objectCategory=Person)(objectClass=User)(Mail=%%i*))" -Attr description -L
      ) ELSE (
      SET Qry=DSQuery * DomainRoot -Filter "(&(objectCategory=Person)(objectClass=User)(sAMAccountName=%%i*))" -Attr description -L
      )
      FOR /F "Delims=*" %%x IN ('!Qry!') Do (Echo %%i : %%x >>C:\DescReport.txt)      
)
Goto EndScript
:ShowErr
Echo 'UserIDs.txt' file does not exist or file is empty!
:EndScript
ENDLOCAL
:: *** SCRIPT END ***
0
 
zoofanCommented:
you asked for "or" do you need the description and the email address for all users?

zf
0
 
bsharathAuthor Commented:
zoofan.

I may have the emailid or Nt login in the txt file.It should query any of this and get the description of these users...
0
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.

 
zoofanCommented:
What about just querying the entire directory and creating a master list of all users returning,

loginname,description,emailaddress


to a csv file?

zf
0
 
zoofanCommented:
and acutally you can add any other attributes you want into the spreadsheet as well.


zf
0
 
bsharathAuthor Commented:
I have this method but want to just find data which i have as i dout that these details are not correct...
As in the description in the ads i have the Employee id's of the user.This would help me find the data in there
0
 
bsharathAuthor Commented:
Farhan.This works great for email id's but not for NT logins....
0
 
Farhan KaziSystems EngineerCommented:
Can you please post what you have inside UserIDs.txt file.
0
 
bsharathAuthor Commented:
I have this

Bramha.Reddy@plc.com
Kumaresan.Vaiyapuri@.com
sharathr
venuk
0
 
Farhan KaziSystems EngineerCommented:
Apply following commands and post results.

DSQuery * DomainRoot -Filter "(&(objectCategory=Person)(objectClass=User)(sAMAccountName=sharathr*))" -Attr description -L

DSQuery * -Filter "(&(objectCategory=Person)(objectClass=User)(sAMAccountName=venuk*))" -Attr description -L
0
 
bsharathAuthor Commented:
C:\>DSQuery * DomainRoot -Filter "(&(objectCategory=Person)(objectClass=User)(sA
MAccountName=sharathr*))" -Attr description -L
12879
C:\>DSQuery * -Filter "(&(objectCategory=Person)(objectClass=User)(sAMAccountNam
e=venugopalk*))" -Attr description -L
23133
0
 
Farhan KaziSystems EngineerCommented:
Above script should work perfectly please check UserIDs.txt for correct user ID's. Enter following data into notepad and save it UserIDs.txt name. While saving this file make sure you have selected 'ANSI' encoding scheme.

venugopalk
Bramha.Reddy@plc.com
Kumaresan.Vaiyapuri@plc.com

0
 
bsharathAuthor Commented:
Sorry farhan.

I dont know what's going wrong with my machines.Some times it works and some times give error.Henceforth i shall make sure i shall check in many machines and post the results to you.

Thanks
0
 
Farhan KaziSystems EngineerCommented:
What is the service pack level of these machines? are these machines fully updated? What Antivirus program is installed on them?
0
 
bsharathAuthor Commented:
OS is windows 2003 with Sp2 and Scanner is Sophos antivirus
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.