Find Last Logon Time For An Exchange 2010 Mailbox

Share & Comment

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!

Share & Comment
Subscribe for Updates
Never miss a blog post again

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

  1. Rusty Shackleford

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

    Reply
    1. Rajith Enchiparambil Post author

      Thanks for the tip Rusty. To take it further, we can use Get-Mailbox -ResultSize Unlimited | Where {$_.RecipientTypeDetails -eq “UserMailbox”} so that it doesn’t pick any resource mailboxes.

      Reply
  2. Saiyan

    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

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>