The Publishing Cache of SP2010 WebApplications

By | 2010-10-11

In a recent post I talked about the publishing cache. It turns out this also applies for Classic Authentication WebApplications.

(from the original post:)
Have a look into your Developer Dashboard to see what is going on:

The warning and critical error are:

  • 7362 – Warning Publishing Cache
  • 7363 – Critical Publishing Cache

I have created a script to set the cacheSuperAccount and cacheReaderAccount on each webapplication in the farm. Be sure to create two seperate domain user accounts first. Then use this script from within you SP2010 PowerShell Prompt. It works on both Classic and Claims Based Authentication WebApps.
Usage:

.script.ps1 -cacheSuperAccount "domainsuperuser" -cacheReaderAccount "domainsuperreader"

The updated PowerShell Script:

param([string]$cacheSuperAccount= "sp2010superuser",[string]$cacheReaderAccount= "sp2010superreader")

write-host ""
write-host -f White "Configure the WebApp property: portalsuperuseraccount and portalsuperreaderaccount"

write-host ""
write-host -f Green "Stef van Hooijdonk - v1.0"
# http://stefvanhooijdonk.com/2010/07/06/claims-based-authentication-and-the-publishingcache/
write-host ""

$snapin="Microsoft.SharePoint.PowerShell"
if (get-pssnapin $snapin -ea "silentlycontinue") {
	write-host -f Green "PSsnapin $snapin is loaded"
}
else {	
	if (get-pssnapin $snapin -registered -ea "silentlycontinue") {
		write-host -f Green "PSsnapin $snapin is registered"
		Add-PSSnapin $snapin
		write-host -f Green "PSsnapin $snapin is loaded"
	}
	else {
		write-host -f Red "PSSnapin $snapin not found" 
	}
}

[void][System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint")

write-host -f Green "Getting current Farm"
$farm = Get-SPFarm

$cacheSuperAccountCL = New-SPClaimsPrincipal -Identity $cacheSuperAccount -IdentityType WindowsSamAccountName 
$cacheReaderAccountCL= New-SPClaimsPrincipal -Identity $cacheReaderAccount -IdentityType WindowsSamAccountName 
$cacheSuperAccountCL = $cacheSuperAccountCL.ToEncodedString()
$cacheReaderAccountCL= $cacheReaderAccountCL.ToEncodedString()

write-host ""
write-host -f Green "Going to loop WebApplications"

Get-SPWebApplication | foreach-object { 

	write-host ""

	if ($_.UseClaimsAuthentication -eq $true ) {	

		write-host -f white $_.Url " is a Claims Based Authentication WebApp"

		write-host -f yellow " - Setting Policy: $cacheSuperAccountCL to Full Control for WebApp" $_.Url
		$policy1 = $_.Policies.Add($cacheSuperAccountCL ,$cacheSuperAccount )
		$policy1.PolicyRoleBindings.Add( $_.PolicyRoles.GetSpecialRole( [Microsoft.SharePoint.Administration.SPPolicyRoleType]::FullControl) ) 

		write-host -f yellow " - Setting Property: portalsuperuseraccount $cacheSuperAccountCL for" $_.Url
		$_.Properties["portalsuperuseraccount"] = $cacheSuperAccountCL

		write-host -f yellow " - Setting Policy: $cacheReaderAccountCL to Full Read for WebApp" $_.Url
		$policy2 = $_.Policies.Add($cacheReaderAccountCL ,$cacheReaderAccount )
		$policy2.PolicyRoleBindings.Add( $_.PolicyRoles.GetSpecialRole( [Microsoft.SharePoint.Administration.SPPolicyRoleType]::FullRead) ) 

	
		write-host -f yellow " - Setting Property: portalsuperreaderaccount $cacheReaderAccountCL for" $_.Url
		$_.Properties["portalsuperreaderaccount"] = $cacheReaderAccountCL
	}
	else  {
		write-host -f white $_.Url " is a Classic Authentication WebApp"

		write-host -f yellow " - Setting Policy: $cacheSuperAccount to Full Control for WebApp" $_.Url
		$policy1 = $_.Policies.Add($cacheSuperAccount ,$cacheSuperAccount )
		$policy1.PolicyRoleBindings.Add( $_.PolicyRoles.GetSpecialRole( [Microsoft.SharePoint.Administration.SPPolicyRoleType]::FullControl) ) 

		write-host -f yellow " - Setting Property: portalsuperuseraccount $cacheSuperAccount for" $_.Url
		$_.Properties["portalsuperuseraccount"] = "$cacheSuperAccount"

		write-host -f yellow " - Setting Policy: $cacheReaderAccount to Full Read for WebApp" $_.Url
		$policy2 = $_.Policies.Add($cacheReaderAccount ,$cacheReaderAccount )
		$policy2.PolicyRoleBindings.Add( $_.PolicyRoles.GetSpecialRole( [Microsoft.SharePoint.Administration.SPPolicyRoleType]::FullRead) ) 

	
		write-host -f yellow " - Setting Property: portalsuperreaderaccount $cacheReaderAccount for" $_.Url
		$_.Properties["portalsuperreaderaccount"] = "$cacheReaderAccount"
	}

	$_.Update()	
	write-host "Saved properties"
}

Write ""
Write-host -f red "Going to run IISReset"
IISreset /noforce
Write ""

2 thoughts on “The Publishing Cache of SP2010 WebApplications

  1. John Champion

    Great script – thanks!

    Question: Should the Local Service account be removed as well? After running the script the accounts are added but Local Service remains with Full Read.

    Reply
  2. Pingback: Setting the SharePoint object caching accounts (superuseraccount | superreaderaccount) « Donal Conlon

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.