TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
mgm tech
NA
26
2.3k
Enable versioning on site collection and subsites
Sep 7 2017 6:51 PM
I have a script that enable a site collection library versioning. However, I need help on enable versioning not just at the site collection level but subsite and sub-subsite. Please help.
function Set-SPOListsVersioning
{
param (
[Parameter(Mandatory=$true,Position=1)]
[string]$Username,
[Parameter(Mandatory=$true,Position=2)]
$password,
[Parameter(Mandatory=$true,Position=3)]
[string]$Url,
[Parameter(Mandatory=$true,Position=4)]
[bool]$Versioning
)
$ctx=New-Object Microsoft.SharePoint.Client.ClientContext($Url)
$ctx.Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($Username, $password)
$ctx.ExecuteQuery()
$ctx.Load($ctx.Web.Lists)
$ctx.Load($ctx.Web)
$ctx.Load($ctx.Web.Webs)
$ctx.ExecuteQuery()
Foreach($ll in $ctx.Web.Lists)
{
if ($ll.BaseType -eq "DocumentLibrary")
{
$ll.EnableVersioning = $Versioning
$ll.MajorVersionLimit = 200
$ll.Update()
}
try
{
$ctx.ExecuteQuery()
if ($ll.BaseType -eq "DocumentLibrary") {
Write-Host $ll.Title " Done" -ForegroundColor Green
}
}
catch [Net.WebException]
{
Write-Host "Failed" $_.Exception.ToString() -ForegroundColor Red
}
}
}
# Paths to SDK. Please verify location on your computer.
Add-Type -Path "c:\Program Files\Common Files\microsoft shared\Web Server Extensions\15\ISAPI\Microsoft.SharePoint.Client.dll"
Add-Type -Path "c:\Program Files\Common Files\microsoft shared\Web Server Extensions\15\ISAPI\Microsoft.SharePoint.Client.Runtime.dll"
# Insert the credentials and the name of the site and the desired setting: $true or $false
$Username="
[email protected]
"
$AdminPassword=Read-Host -Prompt "Enter password" -AsSecureString
$Url="https://test.sharepoint.com/sites/test1"
$Versioning=$true
Set-SPOListsVersioning -Username $Username -password $AdminPassword -Url $Url -Versioning $Versioning
Reply
Answers (
3
)
SPO Announcements knockoutjs sort observable array.
Restreive list and libraries