Hi john ,
Welcome to Q&A forum!
Yes, you can set the default major version for the entire site through PowerShell. SharePoint in Microsoft 365 Library Settings allows a range of 100-50000 major versions, you can choose within this range. Then run the following PowerShell in the SharePoint Online Management Shell as an admin:
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
#Import SharePoint Online PowerShell Module
Import-Module Microsoft.Online.SharePoint.PowerShell -DisableNameChecking
Function Set-SPOSiteVersionHistoryLimit()
{
param
(
[Parameter(Mandatory=$true)] [string] $SiteURL,
[parameter(Mandatory=$false)][int]$VersioningLimit = 100
)
Try {
#Get Credentials to connect
$Cred= Get-Credential
#Setup the context
$Ctx = New-Object Microsoft.SharePoint.Client.ClientContext($SiteURL)
$Ctx.Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($Cred.Username, $Cred.Password)
#Get All Lists from the Web
$Lists = $Ctx.Web.Lists
$Ctx.Load($Lists)
$Ctx.ExecuteQuery()
#Array to exclude system libraries
$SystemLibraries = @("Form Templates", "Pages", "Preservation Hold Library","Site Assets", "Site Pages", "Images",
"Site Collection Documents", "Site Collection Images","Style Library")
#Get All document libraries
$DocumentLibraries = $Lists | Where {$_.BaseType -eq "DocumentLibrary" -and $_.Hidden -eq $False -and $_.Title -notin $SystemLibraries}
#Set Versioning Limits
ForEach($Library in $DocumentLibraries)
{
#Get the Library's versioning settings
$Library.Retrieve("EnableVersioning")
$Ctx.ExecuteQuery()
#powershell to set limit on version history
If($Library.EnableVersioning)
{
#Set versioning limit
$Library.MajorVersionLimit = $VersioningLimit
$Library.Update()
$Ctx.ExecuteQuery()
Write-host -f Green "Version History Settings has been Updated on '$($Library.Title)'"
}
Else
{
Write-host -f Yellow "Version History is turned-off at '$($Library.Title)'"
}
}
}
Catch {
Write-host -f Red "Error:" $_.Exception.Message
}
}
#Call the function to set version history limit
Set-SPOSiteVersionHistoryLimit -SiteURL "https://domain.sharepoint.com/sites/sitename"
In the test, the value I filled in is 100, and the result is as follows:
Note: please select the appropriate number of versions according to your needs, so as not to take up a lot of memory in the version history and affect the performance of the site.
If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.