Please upgrade your web browser now. Internet Explorer 6 is no longer supported.
Thinking Web Solutions?
We create smart, fun, functional websites that make your web a better place.

Turn on Approval for all publishing sites

Just posting a quick script for updating all 'Pages' libraries to have approval turned on. To create the script use a console app and add references to Microsoft.SharePoint.dll and Microsoft.SharePoint.Publishing.dll. Enjoy!

// get site collection url
if (args.Length != 1)

Console.WriteLine("Please supply a site collection URL"); 
return;
}

string siteName = args[0];

// iterate through each sub site
SPSite site = new SPSite(siteName);
foreach (SPWeb web in site.AllWebs)

// look for a pages lib 
PublishingWeb pubWeb = PublishingWeb.GetPublishingWeb(web);
try 

// turn on approval 
SPList pages = pubWeb.PagesList; 
pages.EnableModeration = true; 
pages.Update(); 
Console.WriteLine("Updated site: {0}" , web.Title); 

// ignore errors that occur if not a publshing site 
catch { continue; }
}
Console.WriteLine("Finished ...");

Post a comment