What It Does
The script is read-only. It never applies a preset or changes a policy. It connects to Exchange Online as your app, reads the preset security policy rules for Standard and Strict, then each anti-spam, anti-phishing, anti-malware, Safe Attachments and Safe Links policy and the default outbound spam policy, and compares the settings with the values Microsoft lists as recommended for the Standard level.
Each checked setting is one row with the area, the policy, the setting, its value, the recommended value and a status of Meets, Below or Info. Info rows give facts that are not judged, such as whether a preset is on, allow lists, or that no policy was found. Safe Links, Safe Attachments and some anti-phishing settings need Defender for Office 365, and where there are none they show as Info.
Read it as a snapshot against one recommendation, not a verdict. A custom policy scoped to a few people, or a setting stronger than recommended, can show as Below or Meets without that mattering. The built-in protection policies are skipped, because Microsoft sets them. The Strict values are not checked, and a setting the policy does not return is not judged.
The answer counts the settings that meet Standard and those that are below, and names the areas with the most below. These findings do not raise an alert. If the ExchangeOnlineManagement module is not installed, the run is skipped.
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 permission Organization.Read.All and the Exchange.ManageAsApp permission.
- Assign the app an Exchange read role, for example Security Reader or Global Reader.
- Install the ExchangeOnlineManagement module (version 3.1 or later) on the computer.
- Read the Below rows against what the client has chosen on purpose before you change anything.
- Use OutputFormat=Csv or ExportPath to keep the rows for a review with the client.
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.
- Example answer: "41 settings checked: 33 meet the Standard recommendation, 8 below (Safe Links 5, anti-spam 3); Standard preset off"
- 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.
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.