Exchange Server is licensed by the number of mailboxes within an organization. Not only do unused Exchange mailboxes consume licenses that could be better allocated elsewhere, but unused or dormant Active Directory accounts also weaken an Exchange organization’s security. There is no native option within Exchange that retrieves a list of unused mailboxes, but PowerShell is up to the task.
| select displayname, lastlogontime
If you have a large number of mailboxes, you can send the results to a CSV file and open it in Excel to sort by the date field. To output the results to a CSV file, add Export-CSV and the file path.
| select displayname, lastlogontime |
Descending Order List
get-mailboxstatistics -database yourdbname | Sort-Object LastLogonTime -Descending export-csv "csvfilepath"