I'm hoping to find a sharepoint powershell script to enable only major versions at the site level. Is this possible?

kewally 0 Reputation points
2024-06-19T14:35:43.98+00:00

Too many folders do ea parent.

I'm hoping to find a sharepoint powershell script to enable only major versions at the site level. Is this possible?

SharePoint
SharePoint
A group of Microsoft Products and technologies used for sharing and managing content, knowledge, and applications.
10,059 questions
PowerShell
PowerShell
A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
2,234 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. AllenXu-MSFT 17,501 Reputation points Microsoft Vendor
    2024-06-20T02:18:19.7166667+00:00

    Hi @kewally,

    Versioning is a list-level setting, so it is impossible to be enabled at the site level. We can enable versioning (only major version) for all existing lists and libraries using below PnP PowerShell.

    $SiteURL = "https://xxx.sharepoint.com"
     
    #Connect to PnP Online
    Connect-PnPOnline -Url $SiteURL -Credentials (Get-Credential)
     
    #Get All Lists from the web
    $Lists = Get-PnPList | Where {$_.Hidden -eq $false}
    ForEach($List in $Lists)
    {
        #Enable versioning and set Number of versions to 50
        Set-PnPList -Identity $List -EnableVersioning $True -MajorVersions 50
        Write-host -f Yellow "Configured Versioning on List:"$List.Title
    }
    

    For more information, take a reference to this article: SharePoint Online: Enable Versioning on All Lists and Libraries using PowerShell .


    If the answer is helpful, please click "Accept as 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.

    0 comments No comments