Commands › Exchange Online

Set-SafeAttachmentPolicy

Exchange Online ExchangeOnlineManagement Set-*

Modify safe attachment policies in your cloud-based organization.

Quick start script

# Set-SafeAttachmentPolicy — 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-SafeAttachmentPolicy
$before | Format-List

# 3. Make the change (dry run first)
Set-SafeAttachmentPolicy -Identity <SafeAttachmentPolicyIdParameter> -WhatIf
Set-SafeAttachmentPolicy -Identity <SafeAttachmentPolicyIdParameter>

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

Syntax

Set-SafeAttachmentPolicy [-Identity] <SafeAttachmentPolicyIdParameter>
 [-Action <SafeAttachmentAction>]
 [-AdminDisplayName <String>]
 [-Confirm]
 [-Enable <Boolean>]
 [-QuarantineTag <String>]
 [-Redirect <Boolean>]
 [-RedirectAddress <SmtpAddress>]
 [-WhatIf]
 [<CommonParameters>]

Parameters (9)

ParameterTypeRequiredWhat it controls
-Identity SafeAttachmentPolicyIdParameter yes The Identity parameter specifies the safe attachment policy that you want to modify.
-Action SafeAttachmentAction The Action parameter specifies the action for the safe attachment policy. Valid values are:
-AdminDisplayName String The AdminDisplayName parameter specifies a description for the policy. If the value contains spaces, enclose the value in quotation marks (").
-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.
-Enable Boolean The Enable parameter works with the Action parameter to specify the action for the safe attachment policy. Valid values are:
-QuarantineTag String The QuarantineTag parameter specifies the quarantine policy that's used on messages that are quarantined as malware by Safe Attachments. You can use any value that uniquely identifies the quarantine policy. For example:
-Redirect Boolean The Redirect parameter specifies whether to deliver messages to an alternate email address if malware is detected in an attachment. Valid values are:
-RedirectAddress SmtpAddress The RedirectAddress parameter specifies the destination email address to deliver messages if malware is detected in an attachment.
-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.