Bearbeiten

Share via


Set-SPOListVersionPolicy

Note

This feature is part of the version history controls preview. If your tenant is not part of the preview or the feature has not rolled out to your tenant, you will get an error when trying to run this cmdlet.

Sets the version policy setting on the document library.

Syntax

Set-SPOListVersionPolicy
   [-Site] <SpoSitePipeBind>
   [-List] <SpoListPipeBind>
   [-EnableAutoExpirationVersionTrim <Boolean>]
   [-MajorVersionLimit <int>]
   [-MajorWithMinorVersionsLimit <int>]
   [-ExpireVersionsAfterDays <int>]
   [<CommonParameters>]

Description

Sets the version policy setting on the document library.

Examples

Example 1

Set-SPOListVersionPolicy -Site https://contoso.sharepoint.com/sites/site1 -List "Documents" -EnableAutoExpirationVersionTrim $true

Example 1 sets automatic version history limits on the document library called "Documents".

EXAMPLE 2

Set-SPOListVersionPolicy -Site https://contoso.sharepoint.com/sites/site1 -List "Documents" -EnableAutoExpirationVersionTrim $false -MajorVersionLimit 500 -MajorWithMinorVersionsLimit 20 -ExpireVersionsAfterDays 30

Example 2 sets manual version histroy limits on the document library called "Documents" by limiting the number of versions and the time (in days) versions are kept.

EXAMPLE 3

Set-SPOListVersionPolicy -Site https://contoso.sharepoint.com/sites/site1 -List "Documents" -EnableAutoExpirationVersionTrim $false -MajorVersionLimit 500 -MajorWithMinorVersionsLimit 20 -ExpireVersionsAfterDays 0

Example 3 sets manual version histroy limits on the document library called "Documents" by limiting the number of versions with no time limits. The new document libraries will use this version setting.

Parameters

-EnableAutoExpirationVersionTrim

Global and SharePoint Administrators can set document library level version history limits settings that universally apply to new versions created.

When version history limits are managed automatically, SharePoint employs an algorithm behind the scenes that deletes (thins out) intermittent older versions that are least likely to be needed, while preserving sufficient high-value versions - more versions in the recent past and fewer farther back in time - in case restores are required.

The valid values are:

  • True - Version history limits for new versions created on the document library will be managed automatically.
  • False - Version history limits for new Versions created on the document library will be managed manually by setting limits to the number of major versions (MajorVersionLimit), number of major with minor versions (MajorWithMinorVersionsLimit) and time set (ExpireVersionsAfterDays). Review the documentation of both parameters to manage your organization's version limits manually.

Note

When version history limits are managed manually (EnableAutoExpirationVersionTrim $false), MajorVersionLimit, MajorWithMinorVersionsLimit and ExpireVersionsAfterDays are required parameters with the following acceptable values: a. MajorVersionLimit accepts values from 1 through 50,000 (inclusive). b. MajorWithMinorVersionsLimit accepts values from 0 through 50,000 (inclusive). c. ExpireVersionsAfterDays accepts values of 0 to Never Expire or values >= 30 to delete versions that exceed that time period. When Version history limits are managed automatically (EnableAutoExpirationVersionTrim $true), setting MajorVersionLimit or ExpireVersionsAfterDays will result in an error as the count limits are set by the service.

PARAMVALUE: $true | $false

Type:Boolean
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False
Applies to:SharePoint Online

-ExpireVersionsAfterDays

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 versions (MajorWithMinorVersionsLimit) and the time period the versions are stored (ExpireVersionsAfterDays). Please check the description of EnableAutoExpirationVersionTrim for more details.

PARAMVALUE: Int32

Type:Int32
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False
Applies to:SharePoint Online

-List

The document library name or Id.

Type:SPOListPipeBind
Position:Named
Default value:None
Required:True
Accept pipeline input:False
Accept wildcard characters:False

-MajorVersionLimit

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 are stored (ExpireVersionsAfterDays). Please check the description of EnableAutoExpirationVersionTrim for more details.

PARAMVALUE: Int32

Type:Int32
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False
Applies to:SharePoint Online

-MajorWithMinorVersionsLimit

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 versions (MajorWithMinorVersionsLimit) and the time period the versions are stored (ExpireVersionsAfterDays). Please check the description of EnableAutoExpirationVersionTrim for more details.

PARAMVALUE: Int32

Type:Int32
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False
Applies to:SharePoint Online

-Site

Specifies the URL of the site.

Type:SpoSitePipeBind
Position:1
Default value:None
Required:True
Accept pipeline input:True
Accept wildcard characters:False
Applies to:SharePoint Online