Commands › Exchange Online
Set-AtpPolicyForO365
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)
Reference facts derived from Microsoft documentation, © Microsoft, licensed CC BY 4.0; restructured with original guidance by serv365.ai.