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

Copper Contributor

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

1 Reply
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