How to Find Last Logon Time for Exchange 2010 Mailbox Users

In Exchange Server 2003 the last logon time for a mailbox was visible in the Exchange System Manager.  For Exchange Server 2007 and 2010 the last logon time was removed from the Exchange Management Console, and so we need to use a differnet method to find this information.

The last logon time of an Exchange 2010 mailbox user can be found by running the Get-MailboxStatistics cmdlet in the Exchange Management Shell.

[PS] C:\>Get-MailboxStatistics "Alan Reid"

DisplayName ItemCount StorageLimitStatus        LastLogonTime
----------- --------- ------------------        -------------
Alan Reid   70163             BelowLimit 1/9/2011 10:59:51 PM

You can also pipe other input into Get-MailboxStatistics, for example to see the statistics for all Exchange 2010 mailbox users on a particular mailbox database.

[PS] C:\>Get-MailboxStatistics -Database MB-BR-01

DisplayName                                         ItemCount StorageLimitStatus        LastLogonTime
-----------                                         --------- ------------------        -------------
Tina Miller                                         51896             BelowLimit
Andrew O'Grady                                      51774             BelowLimit
TestMB BR                                           8                 BelowLimit 1/6/2011 12:16:05 AM
Jas Dowden                                          51517             BelowLimit
Laoise Curtis                                       51702             BelowLimit
Denise Dartnell                                     51804             BelowLimit
Pakwei Dean                                         51567             BelowLimit
Prathee Dar                                         51569             BelowLimit
Michael Phillips                                    51603             BelowLimit
Joy Singh                                           51753             BelowLimit
SystemMailbox{9ef3bf09-f222-4317-b216-3f592ab2f6a4} 45                BelowLimit
Wendy Fyson                                         1724              BelowLimit
Maggie Hengist                                      51099             BelowLimit
Joanna Hughes                                       51853             BelowLimit
Ravi Edmonds                                        51370             BelowLimit
Stuart Beauchamp                                    52192             BelowLimit
Nancy Scott                                         51282             BelowLimit
Harinder Rahman                                     51579             BelowLimit
Sharmila Hafri                                      51520             BelowLimit
Garth Gibbons                                       51691             BelowLimit
Jagir Ward                                          51491             BelowLimit
Rowena Khan                                         52083             BelowLimit
Aisha Bhari                                         4                 BelowLimit
Lydia Haines                                        51690             BelowLimit

In the above example many of the users have no last logon date, because they have not logged on to their mailboxes since they were migrated to Exchange Server 2010. In this type of scenario you may wish to sort the results to see which Exchange 2010 mailbox users are yet to logon to their mailbox since a migration.

[PS] C:\>Get-MailboxStatistics -Server ESP-BR-EX2010 | Sort LastLogonTime -Descending

DisplayName               ItemCount    StorageLimitStatus                                                 LastLogonTime
-----------               ---------    ------------------                                                 -------------
Garth Gibbons             51691                BelowLimit                                          1/9/2011 11:38:00 PM
TestMB BR                 8                    BelowLimit                                          1/6/2011 12:16:05 AM
Nancy Scott               51282                BelowLimit
Harinder Rahman           51579                BelowLimit
Stuart Beauchamp          52193                BelowLimit
Joanna Hughes             51853                BelowLimit
Ravi Edmonds              51370                BelowLimit
Rowena Khan               52083                BelowLimit
Aisha Bhari               4                    BelowLimit
Jagir Ward                51491                BelowLimit
Sharmila Hafri            51520                BelowLimit
Lydia Haines              51690                BelowLimit
Maggie Hengist            51099                BelowLimit
Laoise Curtis             51702                BelowLimit
Denise Dartnell           51804                BelowLimit
Jas Dowden                51517                BelowLimit
Tina Miller               51896                BelowLimit
Andrew O'Grady            51774                BelowLimit
Pakwei Dean               51567                BelowLimit
SystemMailbox{9ef3bf09... 45                   BelowLimit
Wendy Fyson               20642                BelowLimit
Joy Singh                 51753                BelowLimit
Prathee Dar               51569                BelowLimit
Michael Phillips          51603                BelowLimit
About Paul Cunningham

Paul is a Microsoft Exchange Server MVP and publisher of Exchange Server Pro. He also holds several Microsoft certifications including for Exchange Server 2007, 2010 and 2013. Find Paul on Twitter, LinkedIn or Google+, or get in touch for consulting/support engagements.

Comments

  1. This episode coming at you from the depths of the Brisbane Sea… :-D

  2. Terrance Brennan says:

    unfortunately, this information shows whichever account last accessed the mailbox, not actually logged into it. Very often this is not the mailbox owner; but, rather an account that looked at the free/busy information information of the mailbox, access their calendar for a meeting, or service accounts such as BlackBerry.

  3. Another trick I’ve used recently is after a night of mailbox migrations I would do

    ### Store all mailboxes that have moved into a variable named $a and that have a status of completed.

    $a = get-moverequests | ? {$_.Status -eq “Completed”}

    foreach ($i in $a) {get-mailboxstatistics “$i”}

    you can also put a the foreach statement into a variable and then do a count

    $z = foreach ($i in $a) {get-mailboxstatistics “$i”}
    $z.count

    I would run this the next day to see how many people I migrated have actually logged in to the new system. The more I’d see the better.

  4. Thanks this was very helpful. We migrated from SBS2003 so I was looking to provide the same functionality as the View Mailboxes plugin. Was helpful as the server rebooted and I wanted to make sure all users were online with Exchange.

    Cheers

  5. When ever i tired to run the Get-MailboxStatistics cmdlet it give me message
    The term ‘Get-MailboxStatistics’ is not recognized as the name of a cmdlet, function, script file, or operable program.
    Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
    At line:1 char:22
    + Get-MailboxStatistics <<<< t007
    + CategoryInfo : ObjectNotFound: (Get-MailboxStatistics:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException

    ANy idea how to resolve this? otherwise i am not able to run the command .

  6. I want to do the following:

    Get the Display Name and Last LogOn Time for any employee reporting to a specific manager in Active Directory, extract that information to an Excel Spreadsheet (sorted by logon time) and e-mail it.

    How can I do that?

  7. Does this accurately reflect connections from OWA, iphones and the such.
    If so then I have 200 out of 1000 users who have not logged in for 2 years. (which does not suprise me)
    Thanks

    • Yes it should include those types of logins. You could test that yourself by picking an account that hasn’t logged on for years, resetting the password, and doing an OWA login, then checking if the last logon date has updated.

  8. Is there a way to know for sure that the Last Logon Time is for the owner of the mailbox? In other words, if an assistant has permission to open their boss’s mailbox as an Additional Mailbox, does that affect the Logon Time, or is it only if that boss logs in?

    • The LastLoggedOnUserAccount property will tell you who that last logon was registered by.

      [PS] C:\>Get-MailboxStatistics | select lastlog* | fl

      LastLoggedOnUserAccount :
      LastLogoffTime : 28/06/2013 12:51:06 PM
      LastLogonTime : 28/06/2013 12:45:56 PM

  9. I tried using the both command

    Get-MailboxStatistics –Database AP-EDB

    Get-MailboxStatistics –Server EXC01

    but both results didnt exceed after 297 records. the mailbox is more than that. Is this any limitation. How do I list out all mailbox in the EDB ?

    Please advice.

Leave a Comment

*

We are an Authorized DigiCert™ SSL Partner.