Please upgrade your web browser now. Internet Explorer 6 is no longer supported.
Zac Smith
SharePoint, WSS and MOSS development.

Turn on Approval for all publishing sites

by Zac Smith 22-Jul-08, 0 Comments

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 ...");

Categories:
0 responses so far:

     

Post a Comment:
Name:
URL:
Email:
Comments: