Export Office 365 User Last Logon Date to CSV File
This script will connect to Office 365 and export a list of all your Office 365 Mailbox enabled users Last Logon Date/Time to a CSV file. It’s useful for finding out if you’re paying for any licences that aren’t being used!
You can choose to either list all users in your Office 365 tenant or use the -InputFile switch to pass a text file with the UserPrincipalName’s of a subset of users for which you want the data.
To run the script from a Powershell window:
PowerShell:
1 |
.\Get-LastLogonStats.ps1 -Office365Username admin@xxxxxx.onmicrosoft.com -Office365Password Password123 -InputFile c:\Files\InputFile.txt |
If you do not pass an input file to the script, it will return the last logon time of ALL mailboxes in the tenant.