Resolving "The super user account utilized by the cache is not configured." by using PowerShell


We have all seen the following error in the Application Event viewer after installing a clean SharePoint installation and creating site collections (Event ID 7362):

Object Cache: The super user account utilized by the cache is not configured. This can increase the number of cache misses, which causes the page requests to consume unneccesary system resources.

The first time I saw this error I figured there had to be a way to do this in PowerShell. This post helped me achieve my goal: Mirjam’s blog.

Because I implement several new farms each month, I was getting annoyed that I had to set the permissions and then use PowerShell to set the accounts for each web application.

I created the following PowerShell script to enable the caching for all Web applications. The 2 users that are explained in Mirjam’s blog have to already exist in the current environment.

If there are any questions or remarks regarding the script I would be pleased to hear them, so I can update the script and hopefully improve it. So here it is:


# This script will add the superuser and superreader account to the Policy for web app
# and also set the web application properties so that the users will be used for caching
# The script is designed in a way that you do NOT have to adjust the script before use
Add-PSSnapin Microsoft.SharePoint.PowerShell

# Function
function addUsersToPolicyAndProperties
{
$webapps = get-spwebapplication
$superuser = Read-Host "Fill in the SuperUser account: <Domain>\<Username>"
$superreader = Read-Host "Fill in the SuperReader: <Domain>\<Username>"

#foreach statement that will loop through all web applications
foreach($webapp in $webapps)
{
try {
$SUpolicy = $webapp.Policies.Add($superuser,$superuser)
$SUpolicy.PolicyRoleBindings.Add($webapp.PolicyRoles.GetSpecialRole([Microsoft.SharePoint.Administration.SPPolicyRoleType]::FullControl))
$SRpolicy = $webapp.Policies.Add($superreader,$superreader)
$SRpolicy.PolicyRoleBindings.Add($webapp.PolicyRoles.GetSpecialRole([Microsoft.SharePoint.Administration.SPPolicyRoleType]::FullRead))
$webapp.Properties["portalsuperuseraccount"] = [string]$superuser
$webapp.Properties["portalsuperreaderaccount"] = [string]$superreader

$webapp.Update()

Write-Host "$webapp.displayname has been configured correctly"
}
catch
{
Write-Host "Error adding the users for $webapp.displayname" -fore red
}
}
Write-Host "All web applications are done, press any key to exit" -fore green
$x = $host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown")
}
#Call function

addUsersToPolicyAndProperties

Advertisements

One thought on “Resolving "The super user account utilized by the cache is not configured." by using PowerShell

  1. Pingback: Failed to create a custom control ‘PublishingSiteActionsMenuCustomizer’ | EdinKapic.com

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