::REM ----------------- Begin sample batch script ----------------------------- @echo off cls ::REM Get Legacy Exchange DN from AD sample script ::REM By John Seaman, www.japan-page.net/batch ::REM (C)2006, Copylefted under terms of the GNU / GPL echo. echo Getting legacy exchange DN for user %1... echo. ::REM Fix the base and DC fields for your domain. set _base=dc=root,dc=mydomain,dc=com adfind -h domain_controller -b %_base% -f "samAccountName=%1" >_getOdn.out.txt echo. echo DN............................: echo. type _getOdn.out.txt | find "dn:CN=" echo. echo. echo. echo HomeMDB.......................: echo. type _getOdn.out.txt | find "homeMDB:" echo. echo. echo. echo legacyExchangeDN..............: echo. type _getOdn.out.txt | find "legacyExchangeDN:" >_getOdn.odn.txt type _getOdn.odn.txt | t upper echo. echo. ::REM Pause here so you can kick this off from the run bar if desired pause :EOF ::REM ----------------- End sample batch script -----------------------------