Top Menu

Friday, October 3, 2014

Content Approval on Multiple Lists

Scenario:
One of my colleague wanted to activate the Content Approval on a couple of lists and libraries within a site and we know that going to the settings of 25 libraries for the same setting is easy but a pain.

Solution:
This can be done through Powershell.
Add-PSSnapin "Microsoft.SharePoint.PowerShell"

$siteUrl="http://www.SharePointBlue.com"
$lists = @("Documents","New Documents","ListA")


$site=Get-SPSite $siteUrl
$web=$site.RootWeb

ForEach ($listName in $lists) 
{
    try
    {
        $list=$web.Lists[$listName]
        $list.EnableModeration = $false
        $list.Update()

        $MSG = $Now.ToString() +  " | Content Approval activated on list: " + $listName
        write-host $MSG
    }
    catch [system.exception]
    {
        $Now = [System.DateTime]::Now
        $MSG = $Now.ToString() +  "Exception: " + $_.Exception.Message
        write-host -f red $MSG
    }
}

No comments:

Post a Comment

Official SharePoint Documentation

I have recently contributed to the official SharePoint documentation for developement. Check it out here: https://docs.microsoft.com/en-us...