Forum Discussion

Chirannjevi's avatar
Chirannjevi
Copper Contributor
Aug 21, 2020

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?

1 Reply

  • Mwoehrle's avatar
    Mwoehrle
    Brass 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

    Last log in time and date PowerShell script for Office 365 to desktop csv file 

Resources