bsharath
asked on
Check the NT login and email id with ADS
Hi,
I have a excel sheet and a txt file which has all the NT logins and Email id's of all users in the company.I dout that some are wrong.Is there a way to cross check these details with ads and list all data which is not found.
NT login Email ID
Sharathr sharath.reddy@plc.com
Regards
Sharath
I have a excel sheet and a txt file which has all the NT logins and Email id's of all users in the company.I dout that some are wrong.Is there a way to cross check these details with ads and list all data which is not found.
NT login Email ID
Sharathr sharath.reddy@plc.com
Regards
Sharath
read thru this article.. to get started...
http://www.msexchange.org/tutorials/Creating_a_list_of_Users_and_their_email_addresses_in_Exchange_2000_2.html
http://www.msexchange.org/tutorials/Creating_a_list_of_Users_and_their_email_addresses_in_Exchange_2000_2.html
:: ===============
:: READ THIS FIRST
:: ===============
:: * This script MailIDs.txt file on C: drive root, from where it will pick users SAM ID of and email address.
:: 'MailIDs.txt' file should be in following format (space separated):
:: <NTUserID> <Email Address>
:: Like:
:: FKazi fkazi@somedomain.com
:: * Successful run will generate "MailMismatch.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:\MailIDs.txt Goto ShowErr
FOR %%R IN (C:\MailIDs.txt) Do IF %%~zR EQU 0 Goto ShowErr
IF EXIST C:\MailMismatch.txt DEL /F /Q C:\MailMismatch.txt
FOR /F "Tokens=1-2" %%i IN ('Type C:\MailIDs.txt') Do (
Echo Processing: %%i
SET Qry=DSQuery * DomainRoot -Filter "(&(objectCategory=Person) (objectCla ss=User)(s AMAccountN ame=%%i*)) " -Attr Mail -L ^| Find "@"
FOR /F "Tokens=1" %%x IN ('!Qry!') Do (
IF /I NOT "%%j"=="%%x" Echo %%i: Email Mismatch >>C:\MailMismatch.txt
)
)
Goto EndScript
:ShowErr
Echo 'MailIDs.txt' file does not exist or file is empty!
:EndScript
ENDLOCAL
:: *** SCRIPT END ***
:: READ THIS FIRST
:: ===============
:: * This script MailIDs.txt file on C: drive root, from where it will pick users SAM ID of and email address.
:: 'MailIDs.txt' file should be in following format (space separated):
:: <NTUserID> <Email Address>
:: Like:
:: FKazi fkazi@somedomain.com
:: * Successful run will generate "MailMismatch.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:\MailIDs.txt Goto ShowErr
FOR %%R IN (C:\MailIDs.txt) Do IF %%~zR EQU 0 Goto ShowErr
IF EXIST C:\MailMismatch.txt DEL /F /Q C:\MailMismatch.txt
FOR /F "Tokens=1-2" %%i IN ('Type C:\MailIDs.txt') Do (
Echo Processing: %%i
SET Qry=DSQuery * DomainRoot -Filter "(&(objectCategory=Person)
FOR /F "Tokens=1" %%x IN ('!Qry!') Do (
IF /I NOT "%%j"=="%%x" Echo %%i: Email Mismatch >>C:\MailMismatch.txt
)
)
Goto EndScript
:ShowErr
Echo 'MailIDs.txt' file does not exist or file is empty!
:EndScript
ENDLOCAL
:: *** SCRIPT END ***
ASKER
Farhan i get this.
Processing: BramhaR
The process cannot access the file because it is being used by another process.
The process cannot access the file because it is being used by another process.
The process cannot access the file because it is being used by another process.
The process cannot access the file because it is being used by another process.
The process cannot access the file because it is being used by another process.
The process cannot access the file because it is being used by another process.
Processing: KumaresanV
The process cannot access the file because it is being used by another process.
Processing: BramhaR
The process cannot access the file because it is being used by another process.
The process cannot access the file because it is being used by another process.
The process cannot access the file because it is being used by another process.
The process cannot access the file because it is being used by another process.
The process cannot access the file because it is being used by another process.
The process cannot access the file because it is being used by another process.
Processing: KumaresanV
The process cannot access the file because it is being used by another process.
I think there is something wrong with the system where you are running this script!
Restart the system and and then check. Also check this script on some other pc's.
Restart the system and and then check. Also check this script on some other pc's.
ASKER
Ok farhan.
I tried in 5 machines and in one machine i got some thing different.
I got this in the results file.
HariKr: Email Mismatch
HariKr: Email Mismatch
HariKr: Email Mismatch
Jayal: Email Mismatch
Jayal: Email Mismatch
HariSh: Email Mismatch
HariSh: Email Mismatch
HariSh: Email Mismatch
HariSh: Email Mismatch
BalaSu: Email Mismatch
BalaSu: Email Mismatch
BalaSu: Email Mismatch
BalaSu: Email Mismatch
BalaSu: Email Mismatch
BalaSu: Email Mismatch
VijayaK: Email Mismatch
VijayaK: Email Mismatch
VijayaK: Email Mismatch
VijayaK: Email Mismatch
VijayaK: Email Mismatch
VinothK: Email Mismatch
Many names are duplicate and their email id's are correct.
How does this script check
Sharathr Sharath.reddy@plc.com
Should there be onlt 1 space between the nt login and email id?
I tried in 5 machines and in one machine i got some thing different.
I got this in the results file.
HariKr: Email Mismatch
HariKr: Email Mismatch
HariKr: Email Mismatch
Jayal: Email Mismatch
Jayal: Email Mismatch
HariSh: Email Mismatch
HariSh: Email Mismatch
HariSh: Email Mismatch
HariSh: Email Mismatch
BalaSu: Email Mismatch
BalaSu: Email Mismatch
BalaSu: Email Mismatch
BalaSu: Email Mismatch
BalaSu: Email Mismatch
BalaSu: Email Mismatch
VijayaK: Email Mismatch
VijayaK: Email Mismatch
VijayaK: Email Mismatch
VijayaK: Email Mismatch
VijayaK: Email Mismatch
VinothK: Email Mismatch
Many names are duplicate and their email id's are correct.
How does this script check
Sharathr Sharath.reddy@plc.com
Should there be onlt 1 space between the nt login and email id?
ASKER
I can remove the duplicates in the excel but
I get the results like this.
RajeshS Email Mismatch
Rajeshse Email Mismatch
RajeshV Email Mismatch
RameshK Email Mismatch
RameshS Email Mismatch
But when i check the ads or my file the email id's are correct.
I get the results like this.
RajeshS Email Mismatch
Rajeshse Email Mismatch
RajeshV Email Mismatch
RameshK Email Mismatch
RameshS Email Mismatch
But when i check the ads or my file the email id's are correct.
>> "Should there be onlt 1 space between the nt login and email id?" Correct
Above script will compare email address that you have given inside User Properties -> General -> E-mail in AD.
Kindly apply following commands and post the result.
Click Start -> Run -> Cmd.exe
DSQuery * DomainRoot -Filter "(&(objectCategory=Person) (objectCla ss=User)(s AMAccountN ame=HariKr ))" -Attr Mail -L | Find "@"
DSQuery * DomainRoot -Filter "(&(objectCategory=Person) (objectCla ss=User)(s AMAccountN ame=Vijaya K))" -Attr Mail -L | Find "@"
Above script will compare email address that you have given inside User Properties -> General -> E-mail in AD.
Kindly apply following commands and post the result.
Click Start -> Run -> Cmd.exe
DSQuery * DomainRoot -Filter "(&(objectCategory=Person)
DSQuery * DomainRoot -Filter "(&(objectCategory=Person)
ASKER
I get this.
C:\>DSQuery * DomainRoot -Filter "(&(objectCategory=Person) (objectCla ss=User)(s A
MAccountName=HariKr))" -Attr Mail -L | Find "@"
Hari.Krishna@plc.com
C:\>DSQuery * DomainRoot -Filter "(&(objectCategory=Person) (objectCla ss=User)(s A
MAccountName=VijayaK))" -Attr Mail -L | Find "@"
Vijaya.Krishnamoorthy@plc. com
C:\>DSQuery * DomainRoot -Filter "(&(objectCategory=Person)
MAccountName=HariKr))" -Attr Mail -L | Find "@"
Hari.Krishna@plc.com
C:\>DSQuery * DomainRoot -Filter "(&(objectCategory=Person)
MAccountName=VijayaK))" -Attr Mail -L | Find "@"
Vijaya.Krishnamoorthy@plc.
ASKER
I have tried with single space.
I only have this in the file
BramhaR Bramha.Reddy@plc.com
KumaresanV Kumaresan.Vaiyapuri@plc.co m
SusantaK Susanta.Kumar@plc.com
SureshK Suresh.Kandan@plc.com
SivaP Siva.Prasad@plc.com
Thanak Thanasekar.Kasi@plc.com
Umag Uma.Maheswari@plc.com
I get this
BramhaR: Email Mismatch
KumaresanV: Email Mismatch
SusantaK: Email Mismatch
SureshK: Email Mismatch
SivaP: Email Mismatch
Thanak: Email Mismatch
Umag: Email Mismatch
I only have this in the file
BramhaR Bramha.Reddy@plc.com
KumaresanV Kumaresan.Vaiyapuri@plc.co
SusantaK Susanta.Kumar@plc.com
SureshK Suresh.Kandan@plc.com
SivaP Siva.Prasad@plc.com
Thanak Thanasekar.Kasi@plc.com
Umag Uma.Maheswari@plc.com
I get this
BramhaR: Email Mismatch
KumaresanV: Email Mismatch
SusantaK: Email Mismatch
SureshK: Email Mismatch
SivaP: Email Mismatch
Thanak: Email Mismatch
Umag: Email Mismatch
Did you verified the email address inside User Properties -> General -> E-mail in ADS?
ASKER
Yes the email id's are there in user>properties> General > Email in ADS.
Run following script and post the results.
:: ===============
:: READ THIS FIRST
:: ===============
:: * This script MailIDs.txt file on C: drive root, from where it will pick users SAM ID of and email address.
:: 'MailIDs.txt' file should be in following format (space separated):
:: <NTUserID> <Email Address>
:: Like:
:: FKazi fkazi@somedomain.com
:: * Successful run will generate "MailMismatch.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:\MailIDs.txt Goto ShowErr
FOR %%R IN (C:\MailIDs.txt) Do IF %%~zR EQU 0 Goto ShowErr
IF EXIST C:\MailMismatch.txt DEL /F /Q C:\MailMismatch.txt
FOR /F "Tokens=1-2" %%i IN ('Type C:\MailIDs.txt') Do (
SET Qry=DSQuery * -Filter "(&(objectCategory=Person) (objectCla ss=User)(s AMAccountN ame=%%i*)) " -Attr Mail -L ^| Find "@"
FOR /F "Tokens=1" %%x IN ('!Qry!') Do (Echo %%i : [%%j][%%x])
)
Goto EndScript
:ShowErr
Echo 'MailIDs.txt' file does not exist or file is empty!
:EndScript
ENDLOCAL
:: *** SCRIPT END ***
:: ===============
:: READ THIS FIRST
:: ===============
:: * This script MailIDs.txt file on C: drive root, from where it will pick users SAM ID of and email address.
:: 'MailIDs.txt' file should be in following format (space separated):
:: <NTUserID> <Email Address>
:: Like:
:: FKazi fkazi@somedomain.com
:: * Successful run will generate "MailMismatch.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:\MailIDs.txt Goto ShowErr
FOR %%R IN (C:\MailIDs.txt) Do IF %%~zR EQU 0 Goto ShowErr
IF EXIST C:\MailMismatch.txt DEL /F /Q C:\MailMismatch.txt
FOR /F "Tokens=1-2" %%i IN ('Type C:\MailIDs.txt') Do (
SET Qry=DSQuery * -Filter "(&(objectCategory=Person)
FOR /F "Tokens=1" %%x IN ('!Qry!') Do (Echo %%i : [%%j][%%x])
)
Goto EndScript
:ShowErr
Echo 'MailIDs.txt' file does not exist or file is empty!
:EndScript
ENDLOCAL
:: *** SCRIPT END ***
ASKER
I get this.
BramhaR : [Bramha.eddy@plc.com][Bram ha.Reddy@p lc.com]
KumaresanV : [Kumaresan.Vaiyapuri@plc.c om][Kumare san.Vaiyap uri@plc.co m
No results file....
BramhaR : [Bramha.eddy@plc.com][Bram
KumaresanV : [Kumaresan.Vaiyapuri@plc.c
No results file....
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Once you complete that, you can use the EXACT() funtion in excel to verify if they match..