Forum Discussion
Chirannjevi
Aug 21, 2020Copper Contributor
AzureAD users last login time stamp report
Can someone please provide the PowerShell script to run the report of all the AAD licensed users along the last login time stamp?
Mwoehrle
Oct 12, 2020Brass Contributor
Chirannjevi You can try something like below, or you can use the reports from your O365 admin center.....O365 admin center -> Reports -> Usage -> Active users.
$LiveCred = Get-Credential
$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://ps.outlook.com/powershell/ -Credential $LiveCred -Authentication Basic -AllowRedirection
Set-ExecutionPolicy RemoteSigned
Import-PSSession $Session
(Get-Mailbox) | Foreach {Get-MailboxStatistics $_.Identity | Select DisplayName, LastLogonTime} | Export-CSV $Home\Desktop\LastLogonDate.csv
Remove-PSSession $Session
Link to article below
https://community.spiceworks.com/scripts/show/2290-last-log-in-time-and-date-powershell-script-for-office-365-to-desktop-csv-file