bsharath
asked on
Script that can find all machines that are created today (Added to the Domain)
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
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
Create date means when added to domain or when OS was installed?
ASKER
When added to the Domain
:: * 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
:: * 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
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
ASKER
Farhan this works great can i get created details only from the local Domain
ASKER
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
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
>> 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?
You mean regardless of the date when they were added to Domain?
ASKER
Yes you are right....
Click Start -> Run -> Cmd.exe -> OK
DSQuery * -Filter "(sAMAccountType=805306369 )" -Attr Name whenCreated -limit 0
DSQuery * -Filter "(sAMAccountType=805306369