The Publishing Cache of SP2010 WebApplications

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 "domain\superuser" -cacheReaderAccount "domain\superreader"

The updated PowerShell Script:

param([string]$cacheSuperAccount= "sp2010\superuser",[string]$cacheReaderAccount= "sp2010\superreader")

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 ""
Advertisements

3 Responses to “The Publishing Cache of SP2010 WebApplications”

  1. John Champion Says:

    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.

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

    […] O.Brian has a good script to do this all at once. SharePoint Stef also has a script to handle this. Categories: SharePoint Tags: “SharePoint […]

  3. Sander Says:

    Stef,

    Ontzettend bedankt voor dit handige scriptje.
    Vanwege de cachemissers in de eventlog had ik gisteren de superreader en superuser ingesteld. Vandaag weigerde SharePoint om bibliotheken of lijsten te openen met als error: “Deze gebruiker bestaat niet of is niet uniek.” Jouw scriptje schrijft ze als claims accounts weg en dat was dus de oplossing. Dom dom.

    Nogmaals bedankt.

    Sander.

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: