In your Exchange Environment, you might have users who have not\are not logging onto their mailboxes from N number of days.
What if you are asked to find all of those or the ones specific to a Server\DB.
There can be multiple reasons why you might have to find such users, one of which was to find how many mailboxes aren't being used for past 30 days.
$ExServer = Read-host "`n Enter ServerName";[Datetime]$mydate = (Get-Date).AddDays(-30).Date; $CorrectDate = $mydate -f "G";
Get-mailbox -server $ExServer -resultsize unlimited | Get-MailboxStatistics | ?{($_.LastLogonTime -lt "$CorrectDate") -and ($_.LastLogonTime -ne $null)}
[Datetime]$mydate = (Get-Date).AddDays(-30).Date; $CorrectDate = $mydate -f "G";
Get-mailbox -resultsize unlimited | Get-MailboxStatistics | ?{($_.LastLogonTime -lt "$CorrectDate") -and ($_.LastLogonTime -ne $null)}