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 * -Properties extensionattribute11 | where {`
((extensionAttribute3 -eq "USER") -and `
((((convertyyyymmddtodate $_.extensionattribute11) - $dstartDate).days -ge $nDeltaDaysPlus) -and `
(((convertyyyymmddtodate $_.extensionattribute11) - $dstartDate).days -le $nDeltaDaysMinus)))})