Convert the exact name of the property. You have expiryDate, but the property is msDS-UserPasswordExpiryTimeComputed .
I changed your conversion check as well so that it just does the conversion and compares it to the date using the same language in your Select-Object statement in case the conversion is failing with your method.
Also if unless PowerShell is smart enough to combine those where-object filters (I do not know), you’re probably slowing you script down by calling it multiple time likes that.
Convert the exact name of the property. You have expiryDate, but the property is msDS-UserPasswordExpiryTimeComputed .
I changed your conversion check as well so that it just does the conversion and compares it to the date using the same language in your Select-Object statement in case the conversion is failing with your method.
Also if unless PowerShell is smart enough to combine those where-object filters (I do not know), you’re probably slowing you script down by calling it multiple time likes that.
[/quote]
Thank you, it actually starts working
Per your comment at the end, I tested to put them in variable and using -and, but it failed every time… so I just got stuck like this using multiple pipelines… probably not the best way to do it, I 100% agree.
If I were to get these user data and “set” their expirydate to whatever current date + 30 days, would I have to bracket entire get-aduser filter?
Edit:
Actually there is a slight problem… with your change, i’m getting 95% result… the other 5% it returns error like this:
Exception calling “FromFileTime” with “1” argument(s): "Not a valid Win32 FileTime.
If the expiration time isn’t set, it might be something like [int]::maxvalue, which can’t be converted to a datetime. Maybe it’s better to convert the datetime to a filetime, and compare two filetimes instead.