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 the Author

Paul Cunningham

Paul is a former Microsoft MVP for Office Apps and Services. He works as a consultant, writer, and trainer specializing in Office 365 and Exchange Server. Paul no longer writes for Practical365.com.

Comments

  1. Ajmal

    Get-Mailbox -ResultSize Unlimited | Select-Object DisplayName,SamAccountName,LastLoggedOnUserAccount,LastLogonTime,servername,database,RecipientTypeDetails,PrimarySmtpAddress,HiddenFromAddressListsEnabled | Export-CSV c:\Exchangemailbox2022.csv –

    – I run this command i get email addresses but I un able to fetch lastlogoff and login any idea how to get the report

  2. Alton Dhakiyarr

    Hi mates, its enormous article οn the topic of
    educationandd еntirely explained, kkeep іt up all the timе.

  3. Nate Statton

    Quality articles or revidws iѕ the important tο
    bee a focus for thhe viewers tߋ visit tһe site, that’s ᴡһat thіѕ web site is providing.

  4. Ranjith

    How to check lastlogon details dnoe using a sepcific conncetion .

    Example : owa lastlogon details

  5. Lisa

    Hey I know this is off topic but I was wondering if you knew of any widgets I could add to my blog
    that automatically tweet my newest twitter updates. I’ve
    been looking for a plug-in like this for quite some time and was
    hoping maybe you would have some experience with something like this.
    Please let me know if you run into anything.

    I truly enjoy reading your blog and I look forward to your new updates.

    Bandar bola terpercaya

  6. Ricky

    Great article! picked up a lot from this. Was wondering how i could import a csv and retrieve the lastlogontime stamp based on that csv. What would the query look like?

    Thanks!

  7. said Daoud

    hello,
    i would like to know,

    how can i know the LastExchangeChangedTime of users in several subdomain

    thank you.

  8. Nazir Shah

    How can i make it to display email too in the below command
    Get-MailboxStatistics -Database “db1″ | Select DisplayName, LastLoggedOnUserAccount, Database, ItemCount, TotalItemSize, LastLogonTime, LastLogoffTime | Sort-Object LastLogonTime -Descending | Export-CSV c:mailboxdb1.csv

  9. Dave Ham

    Thanks for the info. I’m curious if there is a way to get the last logon time for the mailbox owner. We have a mail archiver account that will access the mailboxes regularly as part of the archiving process. This makes it hard to pinpoint when the actual user last accessed their mail.

  10. Ivan

    Hi,

    Will this show the last logon specifically for the mailbox owner, or will it reflect any other logons from other users with full permissions?

  11. Egoitz

    Hi,

    I´m using this script to obtain statistics for the mailboxes from one database:

    Get-MailboxStatistics -Database “db1″ | Select DisplayName, LastLoggedOnUserAccount, Database, ItemCount, TotalItemSize, LastLogonTime, LastLogoffTime | Sort-Object LastLogonTime -Descending | Export-CSV c:mailboxdb1.csv

    But I need to get also the field “company” (under organization) where we specify the office where the person works.

    I don´t know what´s the parameter or how to get it.

    Thanks in advance.

  12. John

    Is there anyway to pipe the last time a user access a mailbox that they have permission to, but is not there full time mailbox?

  13. Marco

    Hi,

    Is there a way to get the last logon times of users which i have in a Excel sheet?
    I have around a 160 users/mailboxes in a Excel sheet from which i would like to have the last logon time. Any ideas?

    1. Avatar photo
      Paul Cunningham

      Put the names in a text file and look at using Get-Content to read the file and pipe that into Get-Mailbox etc… or Import-CSV if you’d rather use a CSV file as the source.

      1. sankara

        Hi Paul

        how we can find the usage statistics of shared mail box if the ActiveDirectory account not enabled. Last logon time shows blank for most of the shared accounts. Can you please help us to find the best way to create report based on the usage history, This is for exchange 2010

  14. Jaime

    Is there a way to change the display name to the actual account logon name?

  15. Anand

    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.

  16. Davis

    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?

    1. Avatar photo
      Paul Cunningham

      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

      1. Daniel Chenault

        Unfortunately I’m not getting the desired results. I have a mailbox bsmith of an employee that has been terminated; AD account is disabled and manager is given full access.

        Bsmith left the company two weeks ago. Yet running
        Get-MailboxStatistics | select lastlog* | fl
        shows bsmith last accessed the mailbox this morning. This should show tjones, the manager.

        Ideas?

        1. Jonathan

          Could be the refresh timing or a kerberos ticket not being expired. But also disconnect any mobile devices from the mailbox as it just shows the account connecting, now how it was connecting.

          You could also check the security log and see if it leads you anywhere.

  17. Chris

    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

    1. Avatar photo
      Paul Cunningham

      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.

  18. ATL

    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?

  19. tom

    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 .

  20. Rob WIlloughby

    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

  21. Dan

    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.

  22. Terrance Brennan

    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.

    1. Jacques Yeoh

      Hi brennan

      Are you sure that checking free/busy will trigger the lastloggenonaccount information?

  23. Brendon Davis

    This episode coming at you from the depths of the Brisbane Sea… 😀

Leave a Reply