Find AD computers created on a specific date (Without using Quest)

This topic contains 2 replies, has 2 voices, and was last updated by  Barry Thomson 3 years, 10 months ago.

  • Author
    Posts
  • #12804

    Barry Thomson
    Participant

    Hi,

    Does anyone have a way of finding AD computers created on a specific date, without using the quest AD snapin?

    Currently, I use this simple little one liner... unfortunately I need to be able to do this without the third part snap-in.

    Has anyone ever done this?

    Get-QADComputer -CreatedOn $dateTimePicker1.Text | select SamAccountName, whenCreated

    Many thanks

  • #12808

    Dave Wyatt
    Moderator

    Can you use the Microsoft ActiveDirectory module, or are you limited to the System.DirectoryServices classes?

    Either way, there is a "whenCreated" property that you can filter on. You'll probably need to set up your filter as a range from midnight-to-midnight, as that field appears to contain time data. For example:

    
    # Simulating what is probably in your $dateTimePicker1.Text field.
    $textDate = '1/2/2014'
    
    $startDate = ([datetime]$textDate).Date
    $endDate = $startDate.AddDays(1)
    
    Get-ADComputer -Filter 'whenCreated -ge $startDate -and whenCreated -lt $endDate' -Properties whenCreated |
    Select-Object -Property SamAccountName,whenCreated
    
    
  • #12826

    Barry Thomson
    Participant

    Hi Dave,

    Thank you so much for this. This is perfect!

    Many thanks

You must be logged in to reply to this topic.