Table of Contents
Introduction
In this post, I will be sharing a script that I wrote to generate a report of configured Authentication Methods for users within 365. As there is not currently an easy way to view this information in bulk within the Microsoft Entra portal it can be handy to have a script on hand such as this to be able to quickly and easily generate a report of what is in use. This can then be used to identify whether or not users are using the authentication methods you have configured for them, or in cases where it is not enforced, where users are not meeting your authentication requirements.
Requirements
This script utilises the Microsoft Graph Beta Powershell module to collect information and then format it for the report, meaning you will have to have this installed for this to work. The script will check for the module before running the rest of the report and tell you if this is missing and how to install it.
However, if you would like to install this before the first run, you can do this with the following command:
Depending on your account’s permissions you can choose to install this for yourself or all users using the ‘-Scope’ switch, being either ‘-Scope CurrentUser’ or ‘-Scope All’ respectively.
Graph PowerShell utilises Enterprise app permissions in your 365 tenant to determine what you will be able to access and manipulate while connected in the session. While this script will attempt to connect with the required permissions to complete the task at hand (User.Read.All” & “UserAuthenticationMethod.Read.All), if your account does not already have these permissions you will instead be prompted to accept them upon sign in.
If your account does not have permission to allow this, you will instead have to send a request to your administrator, who will then have to allow these permissions before you can proceed.Â
Another thing to consider is that this script will check and try to create folder locations on the root drive of your device (most commonly the C:\ Drive), so you will need to have write access to this for this script to complete. If you cannot write to your System Drive you can adjust the report save location on Ln31 by changing the $Logpath variable.
Usage
The script itself is fairly simple and requires no adjustments or input once past the logon stage, so the main concern is making sure you have the requirements covered and you are good to go. While running the script will perform 3 basic tasks:
- Pull a list of all users in the connected 365 tenant (only selects users with the User Type ‘Member’ to exclude Guest accounts)
- Go through and pull all of the authentication methods and details for each user that could be found
- Export the results from the above into a .csv file
The Report itself will by default be saved to the C:\temp folder under the name ‘MFAReport.CSV’, if this folder is not found when the script runs it will be created. If this is the case it will display a brief indication that this has been done, and you will be informed where the report was saved (in case you changed this on Ln31) once the script has exported it.
The results will show the following information for each of the users that were found during the process:
- Username: The Display name of the user account
- UPN: The User Principal Name of the user account
- Account Enabled: Is sign in enabled for the user account
- User is Licensed: Is the user account licensed
- Capable of MFA: Does the user have multiple Authentication methods available
- Authentication Methods: All Authentication methods configured for the user account
- Password Created: When the password for the account was created (would likely be when the account was created)
- Authenticator App: The name of the device that the Authenticator app is configured on
- Phone Details: The phone number and type (i.e Mobile, Office etc.) of the configured phone
- FIDO Key: The Name of the FIDO Key in use
- Windows Hello: The name of the device Windows Hello is configured on
- Email Address: The email address configured as a backup authentication method
- TAP is Usable: If the user’s Temporary Access pass is currently valid
- TAP Start Date: When the user’s Temporary Access Pass was created
- TAP Lifetime: How long the Temporary Access Pass is active for in minutes (from the Start Date)
- TAP One Time: Is the user’s Temporary Access Pass valid for one use only
- Passwordless: The device which is configured as the Passwordless device
- Software OAuth: Is a 3rd party authentication app in use
If there is nothing present for any of the details fields it will be set as a hyphen ‘-‘ to indicate that the value is not in use within the report. This was done to avoid null return values from causing information to overlap between users and adds some clarity to the final report.
The results are saved as a .csv file and therefore do not come in a formatted table (image below), so if you are planning to hand these results off to another party it would likely be worth a couple of minutes to format a table with the results and save as a .xlsx file so that you can filter and sort efficiently.
You can run this report multiple times without any issues, however, if there is an existing report in the C:\temp folder with its default name then it will be overwritten. So if you still require the previous report consider either renaming this or moving it to another location.
The Script
Adjustments you can make...
While the script itself will work perfectly fine on its own with no further adjustments, there are some changes you can make for yourself if you want to adjust the format of some of the results shown in the report to more accurately match your requirements.Â
For example, the ‘Password Created’ and ‘TAP Start Date’ fields both use the default date formatting that Microsoft 365 users being ‘MM-dd-yyyy’, this is fine for those that work with 365 reports regularly however might not be appreciated by others (depending on your region and preference for example). This can be adjusted by changing Ln87 and Ln110 to the following respectfully:
You can then adjust the formatting of the date to meet whatever your preference is.
I have already mentioned that you can change the export location for the final report by adjusting the $LogPath variable on Ln31, however if you do this and you would like others to then be able to use your adjusted version, you may also want to consider changing the check for the save location starting on Ln37, or removing this altogether.
I have also mentioned that in its default state, this script will only collect the Authentication methods for accounts with the Usertype ‘Member’, this means only your internal user accounts are looked at and guests are excluded. However if you are planning on looking at what authentication methods are being used on Guest accounts as well you can do so by removing the filter on Ln67, to make it the following
In doing so you will then include all account types in your report so you can see what they have configured as well.
Summary
With the recent depreciation of the AzureAd and MSOLService PowerShell modules, it is time to start adjusting your scripts and workloads over to Microsoft Graph instead. One thing I find myself having to do fairly frequently is exporting the Authentication methods that have been set up by end users into a report to visualise which methods are actually in use and which users need to be addressed.
That being the case I decided to write this PowerShell script to do just that using the Microsoft Graph Beta PowerShell module, and now I would like to share it so you don’t have to do it yourself either.
Author: Curtis Cannon
My name is Curtis, I am a service engineer for an MSP. My focus is on specialising on Azure/Entra ID and other related cloud technologies found in the Microsoft 365 Suite. This content has been written from my own knowledge on the subject in question, and any opinions given throughout the post are mine and do not represent the opinion of others.
Related Posts
Sending Organisation Wide Messages in 365 Admin Center
In this post I will cover Organisations message in the 365 Admin Center and how they can be used to streamline notification delivery to end users.
Generate a Device Compliance Report Using PowerShell
In this post I will share a script I have created to generate a report of all managed devices compliance status which will help give you an understanding of which devices need remediating, removing, or have their policies adjusted.
Identify Unassigned Intune Policies with PowerShell
In this post I will share a script I have created to report on all unassigned applications in Intune
