Last Login Details

Glenn Maxwell 10,551 Reputation points

Hi All

I am using exchange 2016 hybrid environment. we create users in onprem and migrate to exchange online and sometimes i also create users using remote mailbox syntax from onprem. i have a test tenant and i have 70 Office 365 licenses(50 E5 & 20 E3). i am running out of licenses and i dont want to procure any more Office 365 license as it is a test tenant. Now i have a requirement to provision 20 mailboxes. i want to revoke the licenses of the users who have not logged in last 30 days. From Azure AD i can see last sign-in logs. is this the only logs which gives me the details. and lets say i have csv file of the users in the below format. can i import the csv and get the last signin logs

user1@Company portal .com
user2@Company portal .co

Microsoft Exchange Online Management
Microsoft Exchange Online Management
Microsoft Exchange Online: A Microsoft email and calendaring hosted service.Management: The act or process of organizing, handling, directing or controlling something.
4,298 questions
Exchange Server Management
Exchange Server Management
Exchange Server: A family of Microsoft client/server messaging and collaboration software.Management: The act or process of organizing, handling, directing or controlling something.
7,426 questions
Microsoft Entra ID
Microsoft Entra ID
A Microsoft Entra identity service that provides identity management and access control capabilities. Replaces Azure Active Directory.
20,063 questions
{count} votes

Accepted answer
  1. JimmySalian-2011 41,956 Reputation points

    Hi Glenn,

    You can use GraphAPI to extract the information: user-list

    or the script:

    $LiveCred = Get-Credential  
    $Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri -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  

    Please "Accept the answer" if the information helped you. This will help us and others in the community as well.

    0 comments No comments

0 additional answers

Sort by: Most helpful