[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 180
  • Last Modified:

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
0
bsharath
Asked:
bsharath
  • 5
  • 4
1 Solution
 
Farhan KaziSystems EngineerCommented:
Create date means when added to domain or when OS was installed?
0
 
bsharathAuthor Commented:
When added to the Domain
0
 
Farhan KaziSystems EngineerCommented:
:: * 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
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
bsharathAuthor Commented:
Farhan this works great can i get created details only from the local Domain
0
 
bsharathAuthor 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
0
 
Farhan KaziSystems EngineerCommented:

:: * 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 * -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
0
 
Farhan KaziSystems EngineerCommented:
>> 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?
0
 
bsharathAuthor Commented:
Yes you are right....
0
 
Farhan KaziSystems EngineerCommented:
Click Start -> Run -> Cmd.exe -> OK
DSQuery * -Filter "(sAMAccountType=805306369)" -Attr Name whenCreated -limit 0
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

  • 5
  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now