New-SPOFileArchivePolicy

Creates a new file archive policy for the tenant.

Syntax

Default (Default)

New-SPOFileArchivePolicy
    [-Name <String>]
    -PolicyType <SPOFileArchivePolicyType>
    [-LastAccessDateCriteria <Int32>]
    [-FileTypeCriteria <String[]>]
    [-IsWhatIfMode <Boolean>]
    [<CommonParameters>]

Description

This cmdlet creates a new file archive policy for the connected SharePoint Online tenant. A file archive policy defines the criteria under which files are automatically archived based on their last access date. The policy is created in an Inactive state and must be activated using Set-SPOFileArchivePolicy with -State Active before it takes effect.

Note

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

Examples

Example 1

New-SPOFileArchivePolicy -PolicyType "AllSites" -Name "ArchiveAll"

Creates a new file archive policy named "ArchiveAll" that targets all sites in the tenant, using the default last access date criteria of 24 months.

Example 2

New-SPOFileArchivePolicy -PolicyType "SelectedSites" -Name "ArchiveMarketing" -LastAccessDateCriteria 12 -FileTypeCriteria ".docx", ".pptx", ".xlsx"

Creates a new file archive policy named "ArchiveMarketing" that targets selected sites, archives files not accessed in the last 12 months, and only applies to .docx, .pptx, and .xlsx file types.

Example 3

New-SPOFileArchivePolicy -PolicyType "AllSites" -IsWhatIfMode $true

Creates a new file archive policy in WhatIf mode. When the policy runs, it will report which files would be archived without actually archiving them.

Parameters

-FileTypeCriteria

Specifies an 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. If not specified, all file types are included.

Parameter properties

Type:

String[]

Default value:None
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

-IsWhatIfMode

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 $false or not specified, the policy archives files normally when active.

Parameter properties

Type:Boolean
Default value:None
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

-LastAccessDateCriteria

Specifies the number of months since a file was last accessed before it becomes eligible for archiving. Valid values range from 6 to 48. The default value is 24 months.

Important

The last access date is accurate starting July 2025. Dates before that may be missing access signals from some clients. For critical data, ensure your criteria doesn't archive based on last access dates before July 2025.

Parameter properties

Type:Int32
Default value:None
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

-Name

Specifies a display name for the policy. If not specified, defaults to "MyPolicy".

Parameter properties

Type:String
Default value:None
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

-PolicyType

Specifies whether the policy targets all sites in the tenant or only selected sites. Accepted values are AllSites and SelectedSites. If SelectedSites is chosen, you must add at least one site using Add-SPOSiteToFileArchivePolicy before the policy can be activated.

Parameter properties

Type:SPOFileArchivePolicyType
Default value:None
Accepted values:AllSites, SelectedSites
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