The following command will return ADUser objects for user1 and user2 in PowerShell v3 but null in powershell v2
(@("user1", "user2") | Get-ADUser).Name
If you are using powershell v2, I would suggest trying to change your command to:
Get-ADUser -filter * -Properties accountExpires | Select -ExpandProperty AccountExpires
This will return an array of AccountExpires attributes
Another issue is that you are essentially plugging in a possible array into
[System.DateTime]::FromFileTime($expireDate)
With $expireDate being that possible array. I believe this will only return a time for the first element of the array.
Another possible issue could be that you are checking if whenCreated is greater than the expiration date. Normally this date is going to be less than. All together if you're looking for accounts that have expired I would do something like:
$users = Get-ADUser -filter * -Properties AccountExpires, WhenCreated
foreach ( $user in $users ) {
$span = [DateTime]::FromFileTime($user.AccountExpires) - $user.WhenCreated
if ( $span.Days -eq 90 ) {
# Do Something with user that was set to expire 90 days
}
}