Skip to content
Menu

Users Can Consent to Any App

Reads the tenant's authorization policy and alerts when every user may consent to any app, or to apps Microsoft flags as risky. Limited or off is OK.

Users can consent to any app 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 Users can consent to any app. 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 the tenant's authorization policy: which app consent policies are assigned to ordinary users. It changes nothing.

It alerts when the legacy policy microsoft-user-default-legacy is assigned, which lets every user consent to any app for any permission that does not need an admin, or when allowUserConsentForRiskyApps is true. It is healthy when user consent is off, or limited by microsoft-user-default-low (verified publishers and permissions you classified as low impact), or by a custom policy of your own.

A custom policy is reported in the table and in a warning, because only you know what it allows. A newer built-in policy the script does not know is treated the same way: OK with a warning. The answer says which case applies, for example that user consent is off and only admins can approve apps.

It keeps no state, so a second run gives the same answer until the setting changes. To see which apps users have already consented to, run test-risky-app-consents.

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 what a custom consent policy allows in the Entra admin center, since the script cannot judge it.
  • Change the setting in the Entra admin center if it alerts. The script does not change it.
  • Pair it with test-risky-app-consents to see what users already approved.

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 30 seconds.
  • Example answer: "Users can consent to any app (policy microsoft-user-default-legacy is assigned)"
  • 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-user-consent-settings.ps1 · 969 lines · 54.4 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.