What It Does
The script signs in as your multi-tenant app registration to each tenant in TenantId and reads Microsoft Graph. It changes nothing. The same app and credential are used for every tenant, with admin consent given in each client tenant, and the token is reset for each one.
Each row has Users (enabled member accounts), Admins (distinct users with a directory role assignment; assignments that are only PIM-eligible are not listed), MfaRegisteredPercent (members registered for a strong method), LegacyAuth and Guests. LegacyAuth is a reading, not a proof: Blocked (security defaults) when security defaults are on, Likely blocked (Conditional Access) when an enabled policy for all users and all apps blocks both Exchange ActiveSync and other legacy clients, and Allowed when neither is found.
If the user list cannot be read, the tenant gets an error row and the run goes on. If the role, MFA or policy read fails, only that part of the row is missing and the Error column says why. The run ends in an error when no tenant's user list could be read. Without Entra ID P1, the MFA report is unavailable.
The answer gives how many tenants had a readable user list, how many failed that read and the tenant with the lowest MFA registration. It keeps no state, so a second run simply reads everything again.
Before You Run It
- Register one multi-tenant app and give admin consent for User.Read.All, RoleManagement.Read.Directory, AuditLog.Read.All and Policy.Read.All in every client tenant.
- Put the app's certificate on the computer that runs the script and use its thumbprint.
- List the tenants in TenantId, separated by commas, semicolons or new lines.
- Entra ID P1 is needed in a tenant for the MFA registration figure. Without it that cell reads n/a.
- Read LegacyAuth as a hint and confirm a surprising result in the tenant.
Type and Risk
- Type: Report. It collects facts into a table and never alerts. It exits 0, or 2 when it could not run.
- Risk: Low. It reads and changes nothing.
- Restart: It never restarts the machine.
- Typical run: Under 2 minutes per tenant.
- Example answer: "3 tenant(s) read, 1 failed; lowest MFA registration: fabrikam.onmicrosoft.com 61%"
- 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: One or more client tenants (IDs or domains) separated by comma, semicolon or new line. 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.