Skip to content
Menu

Is Anything Forcing MFA in Microsoft 365

Reads Security Defaults and every Conditional Access policy. OK when Security Defaults is on or an enabled policy requires MFA, otherwise an alert.

Is anything forcing MFA in Microsoft 365 is free for members.

Enter your email to create your free account and get the file.

We'll email you the script and the weekly MSP Outpost email. Unsubscribe anytime. Privacy policy.

Already a member? Sign in.

Be the first to review Is anything forcing MFA in Microsoft 365. Tell other MSPs how it worked for you.

Write a Review

LanguagePowerShell
Runs onWindows 10, 11, Server 2016+, with the app certificate; runs as SYSTEM or a user
NeedsPowerShell 5.1; app registration with Microsoft Graph application permission Policy.Read.All, admin-consented
Read-onlyReads, changes nothing

What It Does

The script signs in as your app registration and reads two things: whether Security Defaults is switched on, and every Conditional Access policy with its state. It changes nothing.

This check reports OK when Security Defaults is on or at least one enabled policy includes the MFA control or an authentication strength that satisfies it. Otherwise it ends in an alert. A policy that is only in report-only or disabled does not count, and the alert answer says how many MFA policies are waiting in report-only.

The table lists Security Defaults and every policy with who it covers. A policy that requires MFA only for a small group still counts, so check the Scope column. A policy whose grant is MFA or another control is counted as requiring MFA.

A tenant without Entra ID P1 has no Conditional Access: the script says so in a warning and judges by Security Defaults alone. It keeps no state, so a second run gives the same answer until something changes. To switch the policies on, deploy them with set-conditional-access-baseline.

Before You Run It

  • Create an app registration with the Graph application permission Policy.Read.All and give admin consent.
  • Put the app's certificate on the computer that runs the script and use its thumbprint.
  • Read the Scope column the first time. A policy for a few users makes the tenant look protected.
  • Expect an alert on a tenant with no Entra ID P1 and Security Defaults off.
  • Schedule it in your RMM and alert on exit 1.

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: "Security Defaults is off and no enabled Conditional Access policy requires MFA (1 MFA policy in report-only)"
  • 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).

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.

The Script

test-conditional-access-state.ps1 · 983 lines · 54.6 KB

Free for Members

Create a free account or sign in to read, copy and download this script.

Welcome Back

Sign in to your MSP Outpost account.