Skip to content
Menu

Shared Mailboxes That Can Sign In

Lists shared and, by default, room and equipment mailboxes with an enabled Entra account. ExcludeMailboxes keeps approved accounts out of the alert.

Shared mailboxes that can sign in 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 Shared mailboxes that can sign in. 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: Organization.Read.All, User.Read.All; Exchange app access (ManageAsApp), read role
Read-onlyReads, changes nothing

What It Does

The script is read-only. It connects to Exchange Online as your app and lists the shared mailboxes and, unless you set IncludeResources=false, the room and equipment mailboxes. For each one it reads the matching Entra account from Microsoft Graph and looks at whether the account is enabled and whether it is synced from on-premises Active Directory.

An enabled account is eligible to sign in directly, subject to other access controls. The script reads accountEnabled. It does not test a user's password or access policies. The run ends ALERT when it finds an enabled account outside the exclusion list and names up to three. Otherwise it ends OK.

Use ExcludeMailboxes for any mailbox that must keep direct sign-in, for example one an application uses. Only enabled accounts outside that list appear in the rows. Missing or unreadable Entra account information is skipped with a warning. If the ExchangeOnlineManagement module is not installed, the run is skipped.

To block the ones it finds, run disable-shared-mailbox-sign-in, which does a dry run first.

Before You Run It

  • Register an app for this client with a certificate, and keep the certificate with its private key on the computer that runs the script.
  • Give the app the Microsoft Graph application permissions Organization.Read.All and User.Read.All, and the Exchange.ManageAsApp permission.
  • Assign the app an Exchange read role, for example Global Reader.
  • Install the ExchangeOnlineManagement module (version 3.1 or later) on the computer.
  • List in ExcludeMailboxes any mailbox that must stay signed in, so it does not alert every run.
  • 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 5 minutes on a large tenant.
  • Example answer: "Sign-in enabled on 2 shared/resource mailbox(es): [shared mailbox sign-in] (shared); [room mailbox sign-in] (room)"
  • 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's tenant ID (a GUID) or domain such as contoso.onmicrosoft.com. Required.
  • ClientId: The app registration's Application (client) ID, a GUID. Required.
  • CertificateThumbprint: Thumbprint of the app's certificate, with its private key in LocalMachine\My or CurrentUser\My on this computer. Preferred. Leave empty to use the ClientSecret environment variable.
  • IncludeResources: true (default) to check room and equipment mailboxes as well as shared mailboxes.
  • ExcludeMailboxes: Addresses (or UPNs) that are allowed to have sign-in enabled, separated by comma, semicolon or new line. Default none.

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-shared-mailbox-sign-in.ps1 · 1009 lines · 55.8 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.