Skip to content

feat: add site version policy modes (Set-PnPSiteVersionPolicy) with expiration - #12

Merged
luigilink merged 3 commits into
mainfrom
feature/site-version-policy
Jul 15, 2026
Merged

feat: add site version policy modes (Set-PnPSiteVersionPolicy) with expiration#12
luigilink merged 3 commits into
mainfrom
feature/site-version-policy

Conversation

@luigilink

Copy link
Copy Markdown
Owner

Closes #11

Summary

Adds first-class support for the modern SharePoint Online version-history model via Set-PnPSiteVersionPolicy, including the customer-requested version expiration (ExpireVersionsAfterDays). The existing per-library count-based Set-PnPList behaviour is kept and remains the default.

New JSON properties

Property Values Description
VersionPolicyMode Legacy (default) / AutoExpiration / ExpireAfter / NoExpiration / InheritFromTenant Selects the mechanism.
ExpireVersionsAfterDays integer (0 or >= 30) Expiration window for ExpireAfter; NoExpiration forces 0.
ApplyTo New / Existing / Both (default Both) Target document libraries.

KeepMajorVersions -> -MajorVersions, KeepMinorVersions -> -MajorWithMinorVersions.

Mode mapping

  • AutoExpiration -> -EnableAutoExpirationVersionTrim $true
  • ExpireAfter -> -EnableAutoExpirationVersionTrim $false -ExpireVersionsAfterDays <n>=30> -MajorVersions <n> [-MajorWithMinorVersions <n>]
  • NoExpiration -> -EnableAutoExpirationVersionTrim $false -ExpireVersionsAfterDays 0 -MajorVersions <n>
  • InheritFromTenant -> -InheritFromTenant

Changes

  • Set-SiteVersionPolicy helper honouring ShouldProcess/WhatiF/DryRun; per-site branch selecting Legacy vs site-policy path.
  • Validation: ExpireVersionsAfterDays must be 0 or >= 30; ExpireAfter requires >= 30; VersionPolicyMode/ApplyTo validated against allowed sets.
  • Version bumped to 3.1.0.
  • Tests: +14 (79 total, all pass).
  • Docs: CHANGELOG, RELEASE-NOTES (latest only), README, wiki (Configuration/Usage/Home).

Scope

Targets the configured SiteUrls. Enumerating all tenant sites (Get-PnPTenantSite) is a planned follow-up.

Notes

No breaking change: default Legacy mode preserves existing behaviour.

Add a VersionPolicyMode property that selects between the existing
per-library count-based path (Legacy, default) and new site-level modes
driven by Set-PnPSiteVersionPolicy: AutoExpiration, ExpireAfter,
NoExpiration and InheritFromTenant. Adds ExpireVersionsAfterDays and
ApplyTo (New/Existing/Both) with validation (0 or >= 30 days), a
Set-SiteVersionPolicy helper honouring ShouldProcess/WhatIf, and keeps
the legacy behaviour fully backward compatible. Bump to 3.1.0.

Refs #11
Add static assertions for the Set-SiteVersionPolicy helper, mode mapping
and ApplyTo, plus a functional context validating the ExpireVersionsAfterDays
rules (0 or >= 30, ExpireAfter requires >= 30). 79 tests pass.

Refs #11
…rsionsAfterDays, ApplyTo)

Add a 3.1.0 section to CHANGELOG, trim RELEASE-NOTES to the latest
version, and document the new site version policy properties and modes
in the Configuration/Usage/Home wiki pages and README.

Refs #11
@luigilink
luigilink merged commit 138f917 into main Jul 15, 2026
1 check passed
@luigilink
luigilink deleted the feature/site-version-policy branch July 15, 2026 08:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add site version policy support (Set-PnPSiteVersionPolicy) with expiration modes

1 participant