Create a list of inactive Exchange mailboxes ; Delete or Clean Mailboxdatabase

Sharing is caring!

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.
Get-mailbox -resultsize unlimited| Get-MailboxStatistics | 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.

Get-mailbox -resultsize unlimited| Get-MailboxStatistics | select displayname, lastlogontime | Export-Csv C:exchinactive.csv
Descending Order List
get-mailboxstatistics -database yourdbname | Sort-Object LastLogonTime -Descending  export-csv "csvfilepath"
  
To remove disconnected mailboxes, rung following command;
Clean-MailboxDatabase dbname

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.