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!
his 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!
The last logon date relates to the time a user last accessed their mailbox using either Outlook, Web Mail or their mobile phone.
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
.Get-LastLogonStats.ps1 -Office365Username [email protected] -Office365Password Password123 -InputFile c:FilesInputFile.txt
NOTE: If you do not pass an input file to the script, it will return the last logon time of ALL mailboxes in the tenant.