JSI Tip 8006. How can I list the computer accounts in my domain that were created after a specified date?

Using a DSQUERY, I have scripted ComputerCreatedAfter.bat, to list the computer accounts in my domain that were created after a specified date.

The syntax for using ComputerCreatedAfter.bat is:

ComputerCreatedAfter YYYYMMDD

Where YYYYMMDD is the specified date, using a 4 digit year, 2 digit month, and 2 digit day.

ComputerCreatedAfter.bat contains:

@echo off
if \{%1\}==\{\} @echo Syntax: ComputerCreatedAfter YYYYMMDD&exit /b 1
setlocal
set after=%1
set query=dsquery * domainroot -filter "(&(objectClass=Computer))" -attr name whenCreated description -limit 0
for /f "Skip=1 Tokens=1-5* Delims=/ " %%c in ('%query%') do (
 set name=%%c
 set created=%%f%%d%%e
 set description=%%h
 call :checkdt
)
endlocal
exit /b 0
:checkdt
if "%created%" LEQ "%after%" goto :EOF
@echo %name% %created% %description%



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