• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 2003
  • Last Modified:

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?
  • 4
  • 4
1 Solution
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 admin2@company.onmicrosoft.com -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:
"https://pod51044psh.outlook.com/powershell-liveid?PSVersion=3.0 "
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        : pod51044psh.outlook.com
Looks like you have a blank line in your input file.  However, your output file should still be generated.
What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

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

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.

Featured Post

Has Powershell sent you back into the Stone Age?

If managing Active Directory using Windows Powershell® is making you feel like you stepped back in time, you are not alone.  For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why.

  • 4
  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now