How to Find Inactive Authentication Methods in Microsoft Entra

It was previously difficult to determine whether a specific authentication method for a user was actively being used. This often required trawling through the Entra sign-in logs or asking the user themselves.

Recently, Microsoft has added the lastUsedDateTime property to the authentication method object, which is returned when you query a user’s authentication methods with the Microsoft Graph API. Using this information, we can now quickly determine if a user has stale authentication methods which can be removed from their account by an admin.

In this article, I will walk you through how you can view the lastUsedDateTime property for an authentication method on a user using Microsoft Graph PowerShell and also provide you with a script to create an interactive authentication methods report for all users in your Microsoft 365 tenant.

Pre-requisites

To query this data, you will need an environment with two key prerequisites: the correct PowerShell module and specific API permissions. 

First, you must install and use the Microsoft.Graph.Authentication PowerShell module. Second, you must connect to the Graph with a set of permissions that allows you to read this data. The minimum permission required is UserAuthenticationMethod.Read.All, although you will likely also need User.Read.All to find the user accounts first.

About this lastUsedDateTime property

The lastUsedDateTime property is available on authentication methods in the Microsoft Graph beta endpoint and it’s a great options for auditing usage of specific authentication methods. This read-only timestamp provides administrators with visibility into when a user last successfully used a particular authentication method, such as their authenticator app, a FIDO2 key, or a phone call. It’s an inherited property, so you’ll find it on derived resources like phoneAuthenticationMethod rather than the base authenticationMethod type.

Admins can now easily identify which authentication methods are actively being used versus those that are stale. This is great for clean-up operations, such as removing old or unused methods that could pose a security risk. Also, it simplifies reporting by allowing you to track the adoption of modern, strong authentication methods across your organisation without having to parse complex sign-in logs.

Reporting on unused authentication methods for a user

To view whether some authentication methods are inactive for a specific user, you need to make an individual request to the authentication/method endpoint for that user, where an array of registered methods will be returned, each containing the lastUsedDateTime property.

$uri = "beta/users/$userid/authentication/methods"
$methods = Invoke-MgGraphRequest -Uri $uri -OutputType PSObject | Select -Expand Value
$methods | Select '@odata.type', lastUsedDateTime

Modify the $userid value for the above command then run it. You should receive an output similar to the below.

Authentication Methods lastUserDateTime response

The @odata.type column shouldn’t be too ambiguous, but for clarity, here is them mapped to a meaningful name:

#microsoft.graph.emailAuthenticationMethod = Email
#microsoft.graph.externalAuthenticationMethod = External Authentication Method
#microsoft.graph.fido2AuthenticationMethod = FIDO2
#microsoft.graph.hardwareOathAuthenticationMethod = Hardware OATH
#microsoft.graph.microsoftAuthenticatorAuthenticationMethod = Microsoft Authenticator
#microsoft.graph.passwordlessMicrosoftAuthenticatorAuthenticationMethod = Passwordless Microsoft Authenticator
#microsoft.graph.passwordAuthenticationMethod = Password
#microsoft.graph.phoneAuthenticationMethod = Phone (sms or voice)
#microsoft.graph.platformCredentialAuthenticationMethod = Platform Credential
#microsoft.graph.qrCodePinAuthenticationMethod = QR Code PIN
#microsoft.graph.softwareOathAuthenticationMethod = Software OATH
#microsoft.graph.temporaryAccessPassAuthenticationMethod = Temporary Access Pass
#microsoft.graph.windowsHelloForBusinessAuthenticationMethod = Windows Hello for Business

Create an inactive authentication methods report

Unfortunately, to obtain this information for all users, you must loop through all users making individual GET requests for each. For ease, I’ve put together a simple script that will obtain all last usage data for all users and their authentication methods and present this into an interactive HTML report. You can download the script from my GitHub.

This report will allow you to filter for specific users, authentication methods and time frames to help you determine which users have authentication methods which can be programmatically removed from their account without impact to improve security.

Inactive Authentication Methods HTML report

It is worth noting that this script is not optimised for large environments, so you are welcome to modify it as you wish.

Daniel Bradley

Daniel Bradley is a UK-based technical architect and Microsoft MVP in Security. He specialises in Microsoft Entra, Intune, and Microsoft Graph PowerShell and is the author of Microsoft Graph PowerShell for Administrators. He writes and edits Our Cloud Network using experience gained from working with Microsoft cloud environments.

Leave a Reply