Link to home
Create AccountLog in
Avatar of Fr. Vandecan
Fr. VandecanFlag 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
Avatar of Fr. Vandecan
Fr. Vandecan
Flag of Belgium image

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
Avatar of Fr. Vandecan
Fr. Vandecan
Flag of Belgium image

Link to home
membership
Create an account to see this answer
Signing up is free. No credit card required.
Create Account