What It Does
The script signs in to one client tenant as your app registration, with a certificate or a secret from the environment, and reads the authentication methods registration report: one record per user with the methods they have registered and whether Microsoft counts them as registered for MFA.
The script alerts when the report marks an included user as not registered for MFA. If that user has only phone methods, the row says those methods are not counted for MFA. With AlertOnWeakMethods on, the default, it flags MFA-registered users whose listed methods are all SMS or voice. The answer gives both counts and the first names.
The script skips guests unless IncludeGuests is true, and skips users in ExcludeUsers. Disabled users are not in Microsoft's report. An empty registration report ends SKIPPED. If the report contains users but every user is excluded, the run ends OK and says so. The report checks registration. Conditional Access and security defaults determine enforcement at sign-in.
Microsoft fills the report for a new tenant within about a day, and updates it a few minutes after a user's methods change. The script keeps no state, so run it on a schedule in your RMM and alert on exit 1.
Before You Run It
- Create an app registration in the client tenant with the Graph application permission AuditLog.Read.All and give admin consent.
- The report needs Entra ID P1 or P2 in the tenant (Microsoft 365 Business Premium includes P1).
- List service accounts and shared mailboxes in ExcludeUsers so they do not alert every run.
Type and Risk
- Type: Monitor. It checks one condition. It exits 1 when it finds the problem, so your RMM can alert on it, 0 when all is well, and 2 when it could not run.
- Risk: Low. It reads and changes nothing.
- Restart: It never restarts the machine.
- Typical run: Under 1 minute.
- Example answer: "MFA: 4 user(s) with no strong method, 7 with SMS or voice only (of 212): [account sign-in A], [account sign-in B], [account sign-in C], +8 more"
- Tested before listing with Windows PowerShell 5.1, run as SYSTEM, against its own test cases and a Microsoft 365 Business Premium test tenant.
Inputs
Pass an input as an argument (-Name value), as an environment variable with the same name, which is how most RMMs pass script variables, or change its default in the param() block at the top of the script. An argument wins over an environment variable, which wins over the default.
- TenantId: The client tenant: its ID (a GUID) or a domain such as contoso.onmicrosoft.com. Required.
- ClientId: The Application (client) ID of the app registration that holds the Graph permissions. Required.
- CertificateThumbprint: Thumbprint of the app's certificate (private key in LocalMachine\My or CurrentUser\My). Preferred. When empty, the app secret is read from the environment variable ClientSecret (a secure/hidden RMM field; never an argument).
- ExcludeUsers: User principal names to skip (service accounts, shared mailboxes), separated by comma, semicolon or new line. Default empty.
- IncludeGuests: true to check guest users as well. Default false.
- AlertOnWeakMethods: true to alert on users whose only methods are SMS or voice calls. Default true.
Every script also takes DryRun, OutputFormat (Text, Answer, Json or Csv), ExportPath and ResultField, which writes the answer to an RMM custom field.
License
Provided "as is" under the MIT License, without warranty of any kind. Test before production use. MSP Outpost and User First Digital Inc. accept no liability for any damage or loss.