Commands › SharePoint Online

Set-SPOFileArchivePolicy

SharePoint Online Microsoft.Online.SharePoint.PowerShell Set-*

Updates an existing file archive policy.

Quick start script

# Set-SPOFileArchivePolicy — quick start (serv365.ai)
# 1. Connect (app-only shown; interactive: omit the certificate parameters)
Connect-SPOService -Url https://$org-admin.sharepoint.com

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

# 3. Make the change
Set-SPOFileArchivePolicy -PolicyId <Guid>

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

Syntax

Set-SPOFileArchivePolicy -PolicyId <Guid> [-Name <String>] [-PolicyType <SPOFileArchivePolicyType>]
 [-LastAccessDateCriteria <Int32>] [-FileTypeCriteria <String[]>] [-IsWhatIfMode <Boolean>] [-State <SPOFileArchivePolicyState>]
 [<CommonParameters>]

Parameters (7)

ParameterTypeRequiredWhat it controls
-FileTypeCriteria String[] Specifies an updated array of file extensions to include in the policy. Only files matching the specified extensions will be considered for archiving. Use the dot-prefixed format. Set to `$null` to include all file types.
-IsWhatIfMode Boolean Specifies whether the policy runs in `WhatIf` mode. When set to `$true`, the policy will evaluate which files meet the archiving criteria and report the results, but will not actually archive any files. When set to...
-LastAccessDateCriteria Int32 Specifies the updated number of months since a file was last accessed before it becomes eligible for archiving. Valid values range from 6 to 48.
-Name String Specifies an updated display name for the policy.
-PolicyId Guid yes Specifies the unique identifier (GUID) of the policy to update.
-PolicyType SPOFileArchivePolicyType Specifies the updated policy type. Accepted values are `AllSites` (targets all sites in the tenant) and `SelectedSites` (targets only sites explicitly added to the policy).
-State SPOFileArchivePolicyState Specifies the updated state of the policy. Accepted values are `Active` and `Inactive`. A policy cannot be set to `Active` unless its PolicyType is `AllSites` or at least one site has been added to it.

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