[FileVersion] Add set site version policy commands #3373
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Before creating a pull request, make sure that you have read the contribution file located at
https://github.com/pnp/powerShell/blob/dev/CONTRIBUTING.md
Type
What is in this Pull Request ?
Add changes to let the Set-PnPSite supports to set version policy on site level.
Valid scenarios
Set-PnPSite -EnableAutoExpirationVersionTrim $true
Set-PnPSite -EnableAutoExpirationVersionTrim $false -MajorVersions 101 -ExpireVersionsAfterDays 201
Set-PnPSite -EnableAutoExpirationVersionTrim $false -MajorVersions 300 -ExpireVersionsAfterDays 0
Set-PnPSite -InheritTenantVersionPolicySettings
Set-PnPSite -EnableAutoExpirationVersionTrim $true -StartApplyVersionPolicySettingToExistingDocLibs
Set-PnPSite -EnableAutoExpirationVersionTrim $false -MajorVersions 102 -MinorVersions 52 -ExpireVersionsAfterDays 202 -StartApplyVersionPolicySettingToExistingDocLibs
Set-PnPSite -EnableAutoExpirationVersionTrim $false -MajorVersions 300 -MinorVersions 70 -ExpireVersionsAfterDays 0 -StartApplyVersionPolicySettingToExistingDocLibs
Set-PnPSite -CancelApplyVersionPolicySettingToExistingDocLibs
Invalid scenarios
--The VersionPolicy related parameters (EnableAutoExpirationVersionTrim, ExpireVersionsAfterDays, MajorVersions, MinorVersions StartApplyVersionPolicySettingToExistingDocLibs, CancelApplyVersionPolicySettingToExistingDocLibs) cannot be set when InheritTenantVersionPolicySettings is specified.
Set-PnPSite -InheritTenantVersionPolicySettings -EnableAutoExpirationVersionTrim $true
Set-PnPSite -InheritTenantVersionPolicySettings -MajorVersions 100
Set-PnPSite -InheritTenantVersionPolicySettings -MinorVersions 50
Set-PnPSite -InheritTenantVersionPolicySettings -ExpireVersionsAfterDays 100
Set-PnPSite -InheritTenantVersionPolicySettings -StartApplyVersionPolicySettingToExistingDocLibs
Set-PnPSite -InheritTenantVersionPolicySettings -CancelApplyVersionPolicySettingToExistingDocLibs
--The VersionPolicy related parameters (EnableAutoExpirationVersionTrim, ExpireVersionsAfterDays, MajorVersions, MinorVersions) cannot be set when CancelApplyVersionPolicySettingToExistingDocLibs is specified.
Set-PnPSite -CancelApplyVersionPolicySettingToExistingDocLibs -EnableAutoExpirationVersionTrim $true
Set-PnPSite -CancelApplyVersionPolicySettingToExistingDocLibs -MajorVersions 100
Set-PnPSite -CancelApplyVersionPolicySettingToExistingDocLibs -MinorVersions 100
Set-PnPSite -CancelApplyVersionPolicySettingToExistingDocLibs -ExpireVersionsAfterDays 100
--Don't specify both StartApplyVersionPolicySettingToExistingDocLibs and CancelApplyVersionPolicySettingToExistingDocLibs.
Set-PnPSite -CancelApplyVersionPolicySettingToExistingDocLibs -StartApplyVersionPolicySettingToExistingDocLibs
--You must specify EnableAutoExpirationVersionTrim when StartApplyVersionPolicySettingToExistingDocLibs is specified
Set-PnPSite -StartApplyVersionPolicySettingToExistingDocLibs
--You must specify ExpireVersionsAfterDays, MajorVersions and MinorVersions when EnableAutoExpirationVersionTrim is false.
Set-PnPSite -EnableAutoExpirationVersionTrim $false -StartApplyVersionPolicySettingToExistingDocLibs
Set-PnPSite -EnableAutoExpirationVersionTrim $false -MajorVersions 100 -StartApplyVersionPolicySettingToExistingDocLibs
Set-PnPSite -EnableAutoExpirationVersionTrim $false -MinorVersions 200 -StartApplyVersionPolicySettingToExistingDocLibs
Set-PnPSite -EnableAutoExpirationVersionTrim $false -ExpireVersionsAfterDays 200 -StartApplyVersionPolicySettingToExistingDocLibs
Set-PnPSite -EnableAutoExpirationVersionTrim $false -MajorVersions 300 -MinorVersions 70 -StartApplyVersionPolicySettingToExistingDocLibs
Set-PnPSite -EnableAutoExpirationVersionTrim $false -MajorVersions 300 -ExpireVersionsAfterDays 0 -StartApplyVersionPolicySettingToExistingDocLibs
Set-PnPSite -EnableAutoExpirationVersionTrim $false -MinorVersions 70 -ExpireVersionsAfterDays 0 -StartApplyVersionPolicySettingToExistingDocLibs
--Don't specify both ExpireVersionsAfterDays and MajorVersions when EnableAutoExpirationVersionTrim is true.
Set-PnPSite -EnableAutoExpirationVersionTrim $true -MajorVersions 100
Set-PnPSite -EnableAutoExpirationVersionTrim $true -ExpireVersionsAfterDays 200
Set-PnPSite -EnableAutoExpirationVersionTrim $true -MajorVersions 100 -ExpireVersionsAfterDays 200
--You must specify both ExpireVersionsAfterDays and MajorVersions when EnableAutoExpirationVersionTrim is false.
Set-PnPSite -EnableAutoExpirationVersionTrim $false -MajorVersions 100
Set-PnPSite -EnableAutoExpirationVersionTrim $false -ExpireVersionsAfterDays 200
--Don't specify MinorVersions when StartApplyVersionPolicySettingToExistingDocLibs is not specified.
Set-PnPSite -EnableAutoExpirationVersionTrim $false -MajorVersions 100 -MinorVersions 40 -ExpireVersionsAfterDays 200
Set-PnPSite -EnableAutoExpirationVersionTrim $false -MinorVersions 40 -ExpireVersionsAfterDays 200
Set-PnPSite -EnableAutoExpirationVersionTrim $false -MajorVersions 100 -MinorVersions 40