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

Daoust ICT
Daoust ICT used Ask the Experts™
on
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
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Daoust ICTIcT service Desk

Author

Commented:
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)))})
IcT service Desk
Commented:
@(Get-ADUser -Filter * -Properties extensionattribute11 | where {`
                        ((extensionAttribute3 -eq "USER") -and `
                        ((((convertyyyymmddtodate $_.extensionattribute11) - $dstartDate).days -ge $nDeltaDaysPlus) -and `
                         (((convertyyyymmddtodate $_.extensionattribute11) - $dstartDate).days -le $nDeltaDaysMinus)))})

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial