AdFind - the Command Line Active Directory Query Tool

15 Nov 2013

Here is the example:

set base=OU=Informatica,OU=Accounts,DC=foo,DC=ad,DC=bar,DC=com  
set dev=CN=Informatica Development,%base%
set qa=CN=Informatica QA,%base%
set prd=CN=Informatica Production,%base%
set sprd=CN=Informatica Service Production,%base%

cat aged_header.txt > %file%

adfind -u foo\testuser -up xxx -b DC=foo,DC=ad,DC=bar,DC=com ^
  -f "(|(|(|(memberOf=%dev%)(memberOf=%qa%))(memberOf=%prd%))(memberOf=%sprd%))" ^
  -tdcs -utc ^
  -sort lastLogonTimestamp ^
  -csv -csvdelim # ^
  -csvnoq displayName sAMAccountName mail userAccountControl lastLogonTimestamp

The AdFind home page is here.

Info about A.D. search query syntax is here.