Share via


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