Office 365 report of which users haven’t logged in for over 30, 60, and 90 days

Posted on 2014-08-04
Last Modified: 2014-08-05
Hi all,
I am going to find out which users haven’t logged in for over 30, 60, and 90 daysexport a list of all your Office 365 Mailbox enabled users Last Logon Date/Time to a CSV file.

I also used the article below but it kept giving me errors.

Do you have any idea to get this report?
Question by:dongocdung
    LVL 38

    Expert Comment

    Provide the errors you're getting and I may be able to help you to run that script.

    Author Comment

    PS C:\Users\lly\Downloads> .\Get-LastLogonStats.ps1 -Office365Username -Office365Password P@ssword -useridfile "c:\importfile\inputfile.csv"

    Security warning
    Run only scripts that you trust. While scripts from the internet can be useful,
     this script can potentially harm your computer. Do you want to run
    [D] Do not run  [R] Run once  [S] Suspend  [?] Help (default is "D"): r
    WARNING: Your connection has been redirected to the following URI:
    " "
    WARNING: The names of some imported commands from the module 'tmp_fsbf3005.fn5'
     include unapproved verbs that might make them less discoverable. To find the
    commands with unapproved verbs, run the Import-Module command again with the
    Verbose parameter. For a list of approved verbs, type Get-Verb.
    Cannot process argument transformation on parameter 'Identity'. Cannot convert
    value "" to type
    Error: "Parameter values of type
    can't be empty. Specify a value, and try again.
    Parameter name: identity"
        + CategoryInfo          : InvalidData: (:) [Get-MailboxStatistics], Parame
        + FullyQualifiedErrorId : ParameterArgumentTransformationError,Get-Mailbox
        + PSComputerName        :
    LVL 38

    Expert Comment

    Looks like you have a blank line in your input file.  However, your output file should still be generated.

    Author Comment

    I used this command to get a list of all users who are inactive.

    Get-mailbox -resultsize unlimited| Get-MailboxStatistics | select displayname, lastlogontime

    However, i want this list only for 30 days, 60 days, and 90 days. How can I modify the command below to get desired list.
    LVL 38

    Accepted Solution

    Here's an example for 30 days.
    Get-Mailbox -resultsize unlimited | Get-MailboxStatistics | Where {$_.LastLogonTime -lt (Get-Date).AddDays(-30)} | select displayname, lastlogontime

    Open in new window


    Author Comment

    I used this command and the got some result more than 30 days

    Steve Del Negro
    Frank Molino                            2/26/2014 6:16:16 AM
    Ama Dubell
    Stephen Speirs
    Archer Thompson
    Noreply_Payroll                         6/10/2014 9:25:13 PM
    Matthew  Peltier                        5/16/2014 7:30:33 AM
    Stephan Tisher                          6/30/2014 9:40:30 AM
    Shared MBX                              4/7/2014 8:18:41 AM
    James Young                             5/15/2014 12:33:51 PM
    Discovery Search Mailbox                3/3/2014 5:24:37 PM
    Bruce Walstad                           6/29/2014 7:55:56 PM
    D'Ann Taflin
    Wendy Jolley-Kabi                       5/29/2014 9:14:31 AM
    LVL 38

    Expert Comment

    Exactly.  It lists users whose last logon is more than 30 days ago.

    Author Comment

    Thanks for your help.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Wish Marketing would stop bothering you?

    Is your marketing department constantly asking for new email signature updates? Are they requesting a different design for every department? Do they need yet another banner added? Don’t let it get you down! There is an easy way to manage all of these requests...

    Suggested Solutions

    Set OWA language and time zone in Exchange for individuals, all users or per database.
    Resolve Outlook connectivity issues after moving mailbox to new Exchange 2016 server
    In this video we show how to create an email address policy in Exchange 2013. We show this process by using the Exchange Admin Center. Log into Exchange Admin Center.:  First we need to log into the Exchange Admin Center. Navigate to the Mail Flow…
    Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

    759 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    9 Experts available now in Live!

    Get 1:1 Help Now