This post is also available in: Polish
Below you can find script which will return all mailboxes where LastLogonTime is older than 90 days ago.
You can easly set this date in variable $days.
Function New-Array {,$args} $Report = New-Array $days = "90" $date_last = (Get-Date).AddDays(-$days) $mailboxes = Get-Mailbox -server mxmbx01 -ResultSize unlimited foreach($mailbox in $mailboxes) { $mbx_DN = $mailbox.DistinguishedName $email = $mailbox.PrimarySmtpAddress.toString() $Stat = Get-MailboxStatistics -Identity $mbx_DN | Where-Object {$_.lastLogonTime -lt $date_last} | Select-Object DisplayName, totalitemsize,LastLogonTime if ($Stat){ $tmp = New-Object System.Object $tmp | Add-Member -type NoteProperty -name DisplayName -value $($stat.DisplayName) $tmp | Add-Member -type NoteProperty -name Email -value $email $tmp | Add-Member -type NoteProperty -name TotalSize_MB -value $($stat.TotalitemSize.value.ToMB()) $tmp | Add-Member -type NoteProperty -name LastLogon -value $($stat.LastLogonTime) $Report += $tmp } } $Report | Export-Csv D:\Scripts\lastlogon_report.csv
As a result of this script, you will get .csv file, with informations DisplayName, email address, size of mailbox in MB, and last logon time.