2

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 Answers 2

4

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.

3
  • 2
    LastLogonTime will be reset to blank if the mailbox is migrated between databases, FYI
    – mfinni
    Feb 9, 2016 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, 2016 at 17:04
  • Yes, that's correct.
    – mfinni
    Feb 10, 2016 at 14:05
0

When you move a mailbox from one database to another, the LastLogonTime gets reset. In this case it would appear blank.

1
  • As it’s currently written, your answer is unclear. Please edit to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers in the help center.
    – Community Bot
    May 28, 2023 at 13:34

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .