Forum Discussion

Tim Jahraus's avatar
Tim Jahraus
Copper Contributor
Sep 29, 2023

Export all users who have not logged in for more than 6 months

Hi,

 

how can i export all (exchange) users who have not logged in for more than 6 months?

PS: On Microsoft Entra/Azure admin center i can find a list/filter but i cannot export this list with necessary attributes. 


Many thanks
Tim

  • The built-in reports expose this data, i.e. https://admin.microsoft.com/Adminportal/Home#/reportsUsage/EmailActivity
    Another option is to use the signInActivity data, but you will have to run some Graph queries for that, and it returns both successful and unsuccessful login attempts, so it's not exactly foolproof. Here's a sample query:

    Select-MgProfile beta
    Get-MgUser -Filter "signInActivity/lastSignInDateTime le $([datetime]::UtcNow.AddDays(-180).ToString("s"))Z" -All:$true

Resources