Home > Powershell, Publishing, SharePoint > Remove SharePoint moderation and approval from publishing sites with powershell

Remove SharePoint moderation and approval from publishing sites with powershell

Publishing approval and moderation are useful features in SharePoint but when you need to build out a site quickly, they can become both tiresome and time consuming.

This script will remove moderation and the approval workflow from all sites in a publishing site collection. I recommend you check-in and approve all pages first, an excellent script which will do this for you can be found here.

$siteUrl = "http://intranet" #UPDATE TO YOUR PUBLISHING SITE URL
$listNames = @("Pages", "Documents", "Images")
$workFlowName = "Page Approval"
$site = Get-SPSite $siteUrl
try
{
	foreach ($web in $site.AllWebs)
	{
		write-host "Site: $web"
		foreach($listName in $listNames)
		{
			$list = $web.Lists[$listName]
			if(!($list -eq $null))
			{
				Write-Host "- Disabling Moderation on" $listName
				$list.EnableModeration = $false
				$list.update()
				$wa = $list.WorkflowAssociations.GetAssociationByName($workFlowName, [System.Globalization.CultureInfo]::CurrentCulture)
				if(!($wa -eq $null))
				{
					Write-Host "- Removing" $wa.Name "from" $listName
					$list.WorkflowAssociations.Remove($wa)
				}
			}
		}
	}
}
finally
{
	$site.Dispose()
}
Advertisements
  1. Chris
    August 26, 2011 at 4:01 pm

    sweet. thx

  2. Søren
    June 7, 2012 at 10:12 am

    Thanks, really helpful.

  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: