New-SPOFileArchivePolicy
Creates a new file archive policy for the tenant.
Syntax
Default (Default)
New-SPOFileArchivePolicy
[-Name <String>]
-PolicyType <SPOFileArchivePolicyType>
[-LastAccessDateCriteria <Int32>]
[-FileTypeCriteria <String[]>]
[-FileTypeExclusionCriteria <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.
Use -PolicyType to choose the scope of the policy: all SharePoint sites in the tenant (AllSites), all OneDrive for Business sites in the tenant (AllODBSites), or only the sites you explicitly add (SelectedSites).
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
Creates a new file archive policy named "ArchiveMarketing" that targets only the sites you add with Add-SPOSiteToFileArchivePolicy, and archives files not accessed in the last 12 months.
Example 3
New-SPOFileArchivePolicy -PolicyType "AllODBSites" -Name "ArchiveOneDrive"
Creates a new file archive policy named "ArchiveOneDrive" that targets all OneDrive for Business sites in the tenant. To exempt individual OneDrive sites, add them as exclusions with Add-SPOSiteToFileArchivePolicy and the -Exclude parameter.
Example 4
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, in dot-prefixed format (for example, .docx). Only files matching the specified extensions are considered for archiving. When omitted, 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 |
-FileTypeExclusionCriteria
Specifies an array of file extensions to exclude from the policy, in dot-prefixed format (for example, .docx). Files matching the specified extensions aren't archived. When omitted, no file types are excluded.
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 the scope of the policy. Accepted values are:
AllSites: The policy applies to all SharePoint sites in the tenant.AllODBSites: The policy applies to all OneDrive for Business sites in the tenant.SelectedSites: The policy applies only to the sites you explicitly add to it.
If you choose SelectedSites, you must add at least one site using Add-SPOSiteToFileArchivePolicy before the policy can be activated. If you choose AllSites or AllODBSites, you can optionally exempt individual sites by adding them with Add-SPOSiteToFileArchivePolicy and the -Exclude parameter.
Parameter properties
| Type: | SPOFileArchivePolicyType |
| Default value: | None |
| Accepted values: | AllSites, SelectedSites, AllODBSites |
| 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.