Add-SPOSiteToFileArchivePolicy

Adds a site to a file archive policy.

Syntax

Default (Default)

Add-SPOSiteToFileArchivePolicy
    -PolicyId 
    -Site 
    [-Exclude]
    []

Description

This cmdlet adds a site to an existing file archive policy, either as an inclusion or as an exclusion.

By default, the site is added as an inclusion. Inclusions are only valid for a policy whose PolicyType is SelectedSites, and at least one site must be added before such a policy can be activated. Adding an inclusion to an AllSites or AllODBSites policy returns an error.

When you use the -Exclude parameter, the site is added as an exclusion and is exempted from the policy when it runs. Exclusions are only valid for a policy whose PolicyType is AllSites or AllODBSites. Adding an exclusion to a SelectedSites policy returns an error.

The site must exist and be eligible for archiving. A single policy can contain a maximum of 1,000 sites, counting inclusions and exclusions together.

Note

This cmdlet is part of the file archive policies feature which is currently in preview.

Examples

Example 1

Add-SPOSiteToFileArchivePolicy -PolicyId "a1b2c3d4-e5f6-7890-abcd-ef1234567890" -Site "https://contoso.sharepoint.com/sites/marketing"

Adds the marketing site to the specified SelectedSites file archive policy, so that the policy applies to it.

Example 2

Add-SPOSiteToFileArchivePolicy -PolicyId "a1b2c3d4-e5f6-7890-abcd-ef1234567890" -Site "https://contoso-my.sharepoint.com/personal/user_contoso_com" -Exclude

Adds a OneDrive for Business site to the specified AllODBSites policy as an exclusion, exempting it from archiving while the policy continues to apply to every other OneDrive site in the tenant.

Parameters

-Exclude

Adds the site as an exclusion instead of an inclusion, exempting it from the policy when the policy runs.

Use this parameter only with a policy whose PolicyType is AllSites or AllODBSites. Omit it when adding sites to a SelectedSites policy.

Parameter properties

Type:SwitchParameter
Default value:False
Supports wildcards:False
DontShow:False

Parameter sets

(All)
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-PolicyId

Specifies the unique identifier (GUID) of the policy to add the site to.

Parameter properties

Type:Guid
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

(All)
Position:Named
Mandatory:True
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-Site

Specifies the URL of the site to add to the policy. The site must exist and be eligible for archiving.

Parameter properties

Type:SpoSitePipeBind
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

(All)
Position:Named
Mandatory:True
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

CommonParameters

This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutBuffer, -OutVariable, -PipelineVariable, -ProgressAction, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.

Inputs

None

Outputs

System.Object