This post is also available in: Polish
Sometimes we need to find when user logged to mailbox for the last time.
To achieve this we need to use Get-MailboxStatistics CMDlet
Below command will display LastLogonTime for mailbox JSmith:
Get-MailboxStatistics JSmith | select DisplayName, LastLogonTime
If we are using shared mailboxes we also should display user account which were used to log to mailbox.
This command will display mailbox name, LastLogonTime and user account used to logon:
Get-MailboxStatistics JSmith | select DisplayName, LastLogonTime, LastLoggedOnUserAccount
When we want to get logon time information for all mailboxes in database or in mailbox server MX01, we need to use Get-Mailbox CMDlet, and pipe result to Get-MailboxStatistics
Below example will return last logon time for all mailboxes supported by MX01 mailbox server:
Get-Mailbox -server MX01 -ResultSize Unlimited | Get-MailboxStatistics | sort LastLogonTime select DisplayName, LastLogonTime, LastLoggedOnUserAccount
When we have lot of mailboxes on our server we need to pipe results to a file like .csv where we can sort and filter results.
To achieve this you need to add this command at the end:
| Out-File d:\scripts\LastLogon_Report.csv
You have to be aware of that LastLogonTime is modified by Microsoft Outlook and all mobile devices used to connect to mailbox. So it doesn’t mean that user logged to mailbox, it can mean that he left running Outlook or has mobile devices connected to mailbox which checks emails in mailbox from time to time.