Skip to content
Menu

Identity Posture of Every Client Tenant

Reads each tenant in a list and reports users, admins, MFA registration, a legacy sign-in policy reading and guests. One unreadable tenant does not stop the run.

Identity posture of every client tenant 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 Identity posture of every client tenant. 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; Graph: User.Read.All, RoleManagement.Read.Directory, AuditLog.Read.All, Policy.Read.All; Entra ID P1
Read-onlyReads, changes nothing

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.

The Script

get-tenant-identity-posture.ps1 · 1051 lines · 59.1 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.