Find Last Logon Time For An Exchange 2010 Mailbox

MS Exchange

I received an email requesting help with a script to figure out the Exchange 2010 mailboxes that haven’t been used for a while. A one-liner in PowerShell will fetch this info (no need of scripts)!

The logic used here is that if a user haven’t logged into a mailbox for a while (unless he/she is on sabbatical or maternity leave), it is safe to assume that the mailboxes can be deleted. But, how can an Exchange admin find this useful piece of info? You guessed it right, using the Exchange Shell ;)

Run the following command to find out the last time it was logged into by a user.

Get-Mailbox –Resultsize Unlimited | Get-MailboxStatistics | Sort LastLogonTime | select Displayname, lastlogontime

You can also export the info into a CSV or HTML file.

Get-Mailbox –Resultsize Unlimited | Get-MailboxStatistics | Sort LastLogonTime | select Displayname, lastlogontime | Convertto-Html | Out-File c:\Lastlogon.html

LastLogontime in Exchange 2010

You can target on a per database basis if you have too many users in your organization.

Get-Mailbox –Resultsize Unlimited –Database dbname | Get-MailboxStatistics | Sort LastLogonTime | select Displayname, lastlogontime

Check for the built-in cmdlets before thinking about scripts. Keep it simple!

Other Popular Articles


MS Exchange

Scripting Agent Initialization Failed: “File is not found” Error During Exchange 2016 Setup

MS Exchange

EAC Access While Co-Existing Exchange 2013 With 2010

MS Exchange

Delete All Calendar Entries In An Exchange 2010 Mailbox

10 thoughts on “Find Last Logon Time For An Exchange 2010 Mailbox”

  1. I have a large number of mailboxes (80K or so). when I run these commands for user only, it ends up with a memory error and I only end up getting a fraction of the MBX’s in the export. How can I run the command in a way where it splits up the dumps or will create however many exports is needed to complete? It works fine for a smaller number of mailboxes… just not the total.

    Reply
  2. Thanks nice share.. How can i get the last logon details for users under a specific OU? where each OU stands for a specific unrelated domain hosted on my exchange server.

    Reply
  3. Be sure to exclude resource mailboxes if you decided to indiscriminately delete mailboxes because they have not been logged into for awhile. :)

    Reply

Leave a Comment