My Blog

Add User Policy using Powershell



# This script will add to user policy for a web application in SharePoint 2010

# and will add few more things to get rid of this event in the event logs:

# Object Cache: The super reader account utilized by the cache does not have sufficient permissions to SharePoint databases.

#  See,


Add-PSSnapin Microsoft.SharePoint.PowerShell -erroraction SilentlyContinue

function SetPolicy ($userOrGroup, $wa)


$user = New-SPClaimsPrincipal -IdentityType WindowsSamAccountName -Identity $userOrGroup

$policy = $wa.Policies.Add($user.ToEncodedString(), $userOrGroup)  



$superUserAccount = "Domain\SuperUserAccount"

$superReaderAccount = "Domain\ServiceMOSSInternet"

$wa = Get-SPWebApplication -Identity ""

SetPolicy -userOrGroup $(whoami) -wa $wa

SetPolicy -userOrGroup $superUserAccount -wa $wa

SetPolicy -userOrGroup $superReaderAccount -wa $wa

$wa.Properties["portalsuperuseraccount"] = $superUserAccount

$wa.Properties["portalsuperreaderaccount"] = $superReaderAccount