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

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?
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Provide the errors you're getting and I may be able to help you to run that script.
dongocdungAuthor Commented:
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        :
Looks like you have a blank line in your input file.  However, your output file should still be generated.
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

dongocdungAuthor Commented:
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.
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


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
dongocdungAuthor Commented:
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
Exactly.  It lists users whose last logon is more than 30 days ago.
dongocdungAuthor Commented:
Thanks for your help.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Office 365

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.