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

Jerold Schulman

October 28, 2003

1 Min Read
ITPro Today logo in a gray background | ITPro Today

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 offsetlocalif exist Address.txt del /q Address.txtif exist %TEMP%Address.tmp del /q %TEMP%Address.tmpset qry=dsquery * domainroot -filter "(&(objectCategory=Person)(objectClass=User))" -attr * -limit 999999for /f "Tokens=1* Delims=:" %%a in ('%qry%') do set attr=%%a&set value=%%b&call :testif defined c ( if defined l (  if defined st (   if defined zip (    if defined sa (    goto next)))))if defined dn @echo %dn%>>%TEMP%Address.tmp:nextif not exist %TEMP%Address.tmp @echo No missing address information.>>%TEMP%Address.tmpsort %TEMP%Address.tmp /o Address.txtREM if exist %TEMP%Address.tmp del /q %TEMP%Address.tmpendlocalgoto :EOF:testif not defined value goto :EOFif /i "%attr%" EQU "objectClass" if /i "%value%" EQU " top" goto ismissif /i "%attr%" EQU "distinguishedName" set dn=%value:~1%&goto :EOFif /i "%attr%" EQU "c" if "%value:~1,1%" NEQ " " set c=%value:~1%&goto :EOFif /i "%attr%" EQU "l" if "%value:~1,1%" NEQ " " set l=%value:~1%&goto :EOFif /i "%attr%" EQU "st" if "%value:~1,1%" NEQ " " set st=%value:~1%&goto :EOFif /i "%attr%" EQU "postalCode" if "%value:~1,1%" NEQ " " set zip=%value:~1%&goto :EOFif /i "%attr%" EQU "streetAddress" if "%value:~1,1%" NEQ " " set sa=%value:~1%&goto :EOFgoto :EOF:ismissif 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.tmpset c=set l=set st=set zip=set sa=



Sign up for the ITPro Today newsletter
Stay on top of the IT universe with commentary, news analysis, how-to's, and tips delivered to your inbox daily.

You May Also Like