We help IT Professionals succeed at work.

Script that can find all machines that are created today (Added to the Domain)

218 Views
Last Modified: 2010-04-16
Hi,

Is there a way i can get a script that can fetch the created date as i mention.By default it has to get todays created machine names.

REgards
Sharath
Comment
Watch Question

Farhan KaziSystems Engineer
CERTIFIED EXPERT
Top Expert 2007

Commented:
Create date means when added to domain or when OS was installed?

Author

Commented:
When added to the Domain
Farhan KaziSystems Engineer
CERTIFIED EXPERT
Top Expert 2007

Commented:
:: * Following script will search and display computer accounts that were created on specified date
:: * If you don't give date as parameter the script will show computer account with current create date
:: * Copy and paste following script into notepad and save it with any name having .cmd extension
::
:: * Syntax:
::                <ScriptName.cmd> [MM/DD/YYYY] [>OutputFile.txt]
::    Examples:
::                WhenCreated.cmd 09/02/2007
::                WhenCreated.cmd 09/02/2007 >C:\OutputFile.txt
::                WhenCreated.cmd
::                WhenCreated.cmd >C:\OutputFile.txt
::
:: SCRIPT START
@ECHO OFF
SETLOCAL EnableDelayedExpansion
SET SDate=
IF {%1}=={} (
  FOR /F "Tokens=2-4 Delims=/ " %%x IN ('Date /T') DO (SET SDate=%%x/%%y/%%z)
) ELSE (SET SDate=%1)
ECHO Computer Accounts Created On: !SDate!
SET Query=DSQuery * ForestRoot -Filter "(sAMAccountType=805306369)" -Attr whenCreated Name -limit 0
FOR /F "Skip=1 Tokens=1-7* Delims=/ " %%a in ('%Query%') DO (
    SET Changed=%%a/%%b/%%c
    SET Username=%%e
      IF !SDate! EQU !Changed! (ECHO %%e))
ENDLOCAL
EXIT /B 0
:: SCRIPT END

Author

Commented:
Farhan this works great can i get created details only from the local Domain

Author

Commented:
Is there a way to get the dates of all the computers in the local Domain.Machines that added to the domain from the ADS
Systems Engineer
CERTIFIED EXPERT
Top Expert 2007
Commented:
Unlock this solution and get a sample of our free trial.
(No credit card required)
UNLOCK SOLUTION
Farhan KaziSystems Engineer
CERTIFIED EXPERT
Top Expert 2007

Commented:
>> Is there a way to get the dates of all the computers in the local Domain. Machines that added to the domain from the ADS

You mean regardless of the date when they were added to Domain?

Author

Commented:
Yes you are right....
Farhan KaziSystems Engineer
CERTIFIED EXPERT
Top Expert 2007

Commented:
Click Start -> Run -> Cmd.exe -> OK
DSQuery * -Filter "(sAMAccountType=805306369)" -Attr Name whenCreated -limit 0
Unlock the solution to this question.
Thanks for using Experts Exchange.

Please provide your email to receive a sample view!

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.