Commands › SharePoint Online

Set-SPOListVersionPolicy

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

Sets the version policy setting on the document library.

Quick start script

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

# 3. Make the change
Set-SPOListVersionPolicy -EnableAutoExpirationVersionTrim <Boolean> -List <SPOListPipeBind> -RemoveVersionExpirationFileTypeOverride <String[]>

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

Syntax — 3 parameter sets

SetPolicy

Set-SPOListVersionPolicy [-Site] <SpoSitePipeBind> -List <SPOListPipeBind>
 -EnableAutoExpirationVersionTrim <Boolean> [-ExpireVersionsAfterDays <Int32>] [-MajorVersionLimit <Int32>]
 [-MajorWithMinorVersionsLimit <Int32>] [-FileTypes <String[]>] [<CommonParameters>]

RemovePolicy

Set-SPOListVersionPolicy [-Site] <SpoSitePipeBind> -List <SPOListPipeBind>
 -RemoveVersionExpirationFileTypeOverride <String[]> [<CommonParameters>]

SyncPolicy

Set-SPOListVersionPolicy [-Site] <SpoSitePipeBind> -List <SPOListPipeBind> [-FileTypes <String[]>] [-Sync]
 [-ExcludeDefaultPolicy] [<CommonParameters>]

Parameters (10)

ParameterTypeRequiredWhat it controls
-EnableAutoExpirationVersionTrim Boolean yes Global and SharePoint Administrators can set document library level version history limits settings that universally apply to new versions created.
-ExcludeDefaultPolicy SwitchParameter Indicates whether to synchronize the default version policy to the default policy of the tenant or the site (if the site this document library is in has broken inheritance for version history limits).
-ExpireVersionsAfterDays Int32 When version history limits are managed manually (`EnableAutoExpirationVersionTrim $false`), admins will need to set the limits to the number of major versions (`MajorVersionLimit`), the number of major with minor...
-FileTypes String[] An array of file type names. The supported file type names are: - Audio - OutlookPST - Video
-List SPOListPipeBind yes The document library name or Id.
-MajorVersionLimit Int32 When version history limits are managed manually (`EnableAutoExpirationVersionTrim $false`), admins will need to set the limits to the number of major versions (`MajorVersionLimit`) and the time period the versions...
-MajorWithMinorVersionsLimit Int32 When version history limits are managed manually (`EnableAutoExpirationVersionTrim $false`), admins will need to set the limits to the number of major versions (`MajorVersionLimit`), the number of major with minor...
-RemoveVersionExpirationFileTypeOverride String[] yes An array of file type names. Removes the version history limit override from a set of file types so that they will follow the default version history limits.
-Site SpoSitePipeBind yes Specifies the URL of the site.
-Sync SwitchParameter Apply the version history limits of the tenant or the site (if the site this document library is in has broken inheritance for version history limits).

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