The requirement is to turn on versioning for all site document libraries, including subsites. Also, the Major version number should be 500.
The following Set-PnPList command can be used to set the Versioning and Major version as 500 for a Document Library
# Set-PnPList -Identity "Documents" -EnableVersioning 1 -MajorVersions 25
The following command can be used to set the Versionins and Major / Minor version numbers.
# In this command the minor version in the UI (as aboove) is the draft version. Set-PnPList -Identity "Documents" -EnableVersioning $true -MajorVersions 25 -EnableMinorVersions $true -MinorVersions 10 #
There are two files to automate the process of turning on versioning. The input file is site2process.CSV. The input file is with list of Site Collection URLs to process.
Url https://m365x162783.sharepoint.com/sites/Test1 https://m365x162783.sharepoint.com/sites/Test2
The script file is located here.
Using the above script you can turn on the versioning of all the document libaries.