Avatar of Fr. Vandecan
Fr. Vandecan
Flag for Belgium asked on

powershell to grab ad users having an extensionattribute stored as a string but representing a date (range of dates need to be retrieved)

dear,
I need to search all user having the extensionattribute < than a date (2017-04-01) and > a date (2017-03-23). lets say the date 2017-04-01 and the 7 days before.

the date is stored as string in the extensionattribute11 on format YYYYMMDD
this is working but I'm not able to combine this with the check a a real date to be sure that I get the result I want.
 
get-aduser -Filter "extensionattribute11 -like '20170401'"

any help would be grateful
Powershell

Avatar of undefined
Last Comment
Fr. Vandecan

8/22/2022 - Mon
Fr. Vandecan

ASKER
found myself !
@(Get-ADUser -Filter * -Properties extensionattribute11 | where {`
                        ((extensionAttribute3 -eq "USER") -and `
                        ((((convertyyyymmddtodate $_.extensionattribute11) - $dstartDate).days -ge $nDeltaDaysPlus) -and `
                         (((convertyyyymmddtodate $_.extensionattribute11) - $dstartDate).days -le $nDeltaDaysMinus)))})
ASKER CERTIFIED SOLUTION
Fr. Vandecan

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
This is the best money I have ever spent. I cannot not tell you how many times these folks have saved my bacon. I learn so much from the contributors.
rwheeler23