Commands › Exchange Online

Set-AtpPolicyForO365

Exchange Online ExchangeOnlineManagement Set-*

Modify the settings for the following features in Microsoft Defender for Office 365: - Safe Links protection for supported Office 365 apps. - Safe Documents: Uses Microsoft Defender for Endpoint to scan documents and files that are opened in Protected View in Microsoft 365 apps for enterprise. - Safe Attachments for SharePoint, OneDrive, and Microsoft Teams.

Quick start script

# Set-AtpPolicyForO365 — quick start (serv365.ai)
# 1. Connect (app-only shown; interactive: omit the certificate parameters)
Connect-ExchangeOnline -CertificateThumbprint $thumb -AppId $appId -Organization $org

# 2. Capture the current state first — you cannot roll back what you never recorded
$before = Get-AtpPolicyForO365
$before | Format-List

# 3. Make the change (dry run first)
Set-AtpPolicyForO365  -WhatIf
Set-AtpPolicyForO365

# 4. Verify and diff
$after = Get-AtpPolicyForO365
Compare-Object ($before | Out-String) ($after | Out-String)

Syntax

Set-AtpPolicyForO365 [[-Identity] <AtpPolicyForO365IdParameter>]
 [-AllowSafeDocsOpen <Boolean>]
 [-Confirm]
 [-EnableATPForSPOTeamsODB <Boolean>]
 [-EnableSafeDocs <Boolean>]
 [-WhatIf]
 [<CommonParameters>]

Parameters (6)

ParameterTypeRequiredWhat it controls
-Identity AtpPolicyForO365IdParameter The Identity parameter specifies the policy that you want to modify. There's only one policy named Default.
-AllowSafeDocsOpen Boolean The AllowSafeDocsOpen parameter specifies whether users can click through and bypass the Protected View container even when Safe Documents identifies a file as malicious. Valid values are:
-Confirm SwitchParameter The Confirm switch specifies whether to show or hide the confirmation prompt. How this switch affects the cmdlet depends on whether the cmdlet requires confirmation before proceeding.
-EnableATPForSPOTeamsODB Boolean The EnableATPForSPOTeamsODB parameter enables or disables Safe Attachments for SharePoint, OneDrive, and Microsoft Teams. Valid values are:
-EnableSafeDocs Boolean The EnableSafeDocs parameter enables or disables Safe Documents in organizations with Microsoft 365 A5 or Microsoft 365 E5 Security licenses. Valid values are:
-WhatIf SwitchParameter The WhatIf switch shows what the command does without making any changes. You don't need to specify a value with this switch.

Reference facts derived from Microsoft documentation, © Microsoft, licensed CC BY 4.0; restructured with original guidance by serv365.ai.