1

Hoping someone can help with this/it's an easy to explain issue, but basically I'm looking to find mailboxes in our Exchange 2010 environment that haven't been logged into for more than x days/a certain amount of time.

I've found several powershell scripts online which would/should seem to work by looking at the last logon time attribute for mailbox statistics, but when I try to export (or even just display the results in powershell), there seems to be a lot of mailboxes (but not all) that do not show any information for lastlogontime - it's just blank.

One of the scripts I used for example is below, but wondering if anyone has maybe a better way of finding this information or knows why these results aren't being generated as expected? Thank You in advance for any help you can offer!

Get-Mailbox -ResultSize Unlimited | Get-MailboxStatistics | Where{$_.Lastlogontime -lt (Get-Date).AddDays(-90)} | Select DisplayName, LastLoggedOnUserAccount, LastLogonTime | Export-csv C:\Temp\InactiveUsers.csv
2

Last Logon time being blank usually means it hasn't been used at all. However I personally would adjust the script to remove the requirement for the time limit

Get-Mailbox -ResultSize Unlimited | Get-MailboxStatistics | Select DisplayName, LastLoggedOnUserAccount, LastLogonTime

Then export those results to CSV and sort the results by the dates involved. That will give you a better idea if the results you are getting back are expected.

This script on the TechNet gallery would give you better results though. https://gallery.technet.microsoft.com/scriptcenter/List-Inactive-Mailboxes-on-1ac82ddf as it is based on the last sent item, rather than logon date. If you have a BES or other product that scans the mailboxes then the logon date can be very inaccurate.

  • 1
    LastLogonTime will be reset to blank if the mailbox is migrated between databases, FYI – mfinni Feb 9 '16 at 16:51
  • @mfinni -- Thank You, I wasn't aware of that. This is probably the case because when we off board employees we will move their mailbox to a different database. I'm assuming if the mailbox is logged into again, it will edit the lastlogontime attribute? – n00bAdmin Feb 9 '16 at 17:04
  • Yes, that's correct. – mfinni Feb 10 '16 at 14:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.