Martin, Greg (RTIS)
2010-06-25 19:13:49 UTC
This question is less about the problem at hand and more about how to deal
with the issue of changing types in powershell.
I need to find all the accounts in an OU created more than 30 days ago that
have Never been logged into or haven't been logged into for 60 days. I have
this snippet that uses the quest cmdlet:
Get-QADuser -searchroot "corp.net/user accounts/users/OurOU" |
where { ($_.whencreated -lt ((get-date).adddays(-30)) ) -and
( ( $_.lastLogonTimestamp -like "Never") -or
($_.lastLogonTimestamp -lt ((get-date).adddays(-60))
)
}
The script works for accounts that have never been logged into but throws an
iComparable error when the account has been logged into. I assume its
because I'm trying to compare a date to "Never".
How do I account for the type mismatch between a date the "Never" value?
Thanks
\\Greg
with the issue of changing types in powershell.
I need to find all the accounts in an OU created more than 30 days ago that
have Never been logged into or haven't been logged into for 60 days. I have
this snippet that uses the quest cmdlet:
Get-QADuser -searchroot "corp.net/user accounts/users/OurOU" |
where { ($_.whencreated -lt ((get-date).adddays(-30)) ) -and
( ( $_.lastLogonTimestamp -like "Never") -or
($_.lastLogonTimestamp -lt ((get-date).adddays(-60))
)
}
The script works for accounts that have never been logged into but throws an
iComparable error when the account has been logged into. I assume its
because I'm trying to compare a date to "Never".
How do I account for the type mismatch between a date the "Never" value?
Thanks
\\Greg