Commands › Exchange Online

Set-SharingPolicy

Exchange Online ExchangeOnlineManagement Set-*

Modify existing sharing policies that control how users inside your organization can share free/busy and contact information with users outside your organization.

Quick start script

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

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

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

Syntax

Set-SharingPolicy [-Identity] <SharingPolicyIdParameter>
 [-Confirm]
 [-Default]
 [-DomainController <Fqdn>]
 [-Domains <MultiValuedProperty>]
 [-Enabled <Boolean>]
 [-Name <String>]
 [-WhatIf]
 [<CommonParameters>]

Parameters (8)

ParameterTypeRequiredWhat it controls
-Identity SharingPolicyIdParameter yes The Identity parameter specifies the identity of the sharing policy that you want to modify. You can use one of the following values:
-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.
-Default SwitchParameter The Default switch specifies that the sharing policy is the default sharing policy for all mailboxes. You don't need to specify a value with this switch.
-DomainController Fqdn This parameter is available only in on-premises Exchange.
-Domains MultiValuedProperty The Domains parameter specifies the domains and the associated sharing options for those domains in the sharing policy. Values for this parameter use the basic syntax: `'Domain: SharingPolicyAction'`.
-Enabled Boolean The Enabled parameter specifies whether to enable the sharing policy. Valid values for this parameter are $true or $false. The default is $true.
-Name String The Name parameter specifies the unique name of the sharing policy. The maximum length is 64 characters. If the value contains spaces, enclose the value in quotation marks (").
-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.