JSI Tip 7387. Report users who are missing Active Directory Address information.

using DSQUERY, I have scripted Address.bat to report when a user is missing any information that is configured on the Address tab of the Active Directory Users and Computers snap-in, except for P.O. Box.

The syntax for using Address.bat is:

Address

NOTE: Address.bat creates an Address.txt file in the current directory.

Address.bat contains:

@echo off
setlocal
if exist Address.txt del /q Address.txt
if exist %TEMP%\Address.tmp del /q %TEMP%\Address.tmp
set qry=dsquery * domainroot -filter "(&(objectCategory=Person)(objectClass=User))" -attr * -limit 999999
for /f "Tokens=1* Delims=:" %%a in ('%qry%') do set attr=%%a&set value=%%b&call :test
if defined c (
 if defined l (
  if defined st (
   if defined zip (
    if defined sa (
    goto next
)))))
if defined dn @echo %dn%>>%TEMP%\Address.tmp
:next
if not exist %TEMP%\Address.tmp @echo No missing address information.>>%TEMP%\Address.tmp
sort %TEMP%\Address.tmp /o Address.txt
REM if exist %TEMP%\Address.tmp del /q %TEMP%\Address.tmp
endlocal
goto :EOF
:test
if not defined value goto :EOF
if /i "%attr%" EQU "objectClass" if /i "%value%" EQU " top" goto ismiss
if /i "%attr%" EQU "distinguishedName" set dn=%value:~1%&goto :EOF
if /i "%attr%" EQU "c" if "%value:~1,1%" NEQ " " set c=%value:~1%&goto :EOF
if /i "%attr%" EQU "l" if "%value:~1,1%" NEQ " " set l=%value:~1%&goto :EOF
if /i "%attr%" EQU "st" if "%value:~1,1%" NEQ " " set st=%value:~1%&goto :EOF
if /i "%attr%" EQU "postalCode" if "%value:~1,1%" NEQ " " set zip=%value:~1%&goto :EOF
if /i "%attr%" EQU "streetAddress" if "%value:~1,1%" NEQ " " set sa=%value:~1%&goto :EOF
goto :EOF
:ismiss
if defined c (
 if defined l (
  if defined st (
   if defined zip (
    if defined sa (
     set c=
     set l=
     set st=
     set zip=
     set sa=
     goto :EOF
)))))
if defined dn @echo %dn%>>%TEMP%\Address.tmp
set c=
set l=
set st=
set zip=
set sa=



Hide comments

Comments

  • Allowed HTML tags: <em> <strong> <blockquote> <br> <p>

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.
Publish