Configure Object Cache User Accounts (All in Powershell)

In my last post I explained all the steps to configure the object cache user accounts. It´s so simple and easy… but at the same time boring and long for such a little configuration. So… powershell to the rescue.

Here is the script to run all in one step. We need the URL of the web application, and the object cache user account to use. I thought about writing the script including all web applications but I prefer to do it one by one (just in case…)

PARAMETERS

$wa = Get-SPWebApplication -Identity http://intranet.demos.local

$superUser = “i:0#.w|demosMSSCacheSUser”

$superReader = “i:0#.w|demosMSSCacheSReader”

SCRIPT

$fullPolicy = $wa.Policies.Add($superUser, $superUser)

$fullPolicy.PolicyRoleBindings.Add($wa.PolicyRoles.GetSpecialRole([Microsoft.SharePoint.Administration.SPPolicyRoleType]::FullControl))

$readPolicy = $wa.Policies.Add($superReader, $superReader)

$readPolicy.PolicyRoleBindings.Add($wa.PolicyRoles.GetSpecialRole([Microsoft.SharePoint.Administration.SPPolicyRoleType]::FullRead))

$wa.Properties[“portalsuperuseraccount”] = $superUser;

$wa.Properties[“portalsuperreaderaccount”] = $superReader;

$wa.Update()

Note: The script is assuming we are using Claims Mode authentication for the web app. If this is not your case, change the format of the user account for “domainuser”.

Hope it helps!

Advertisement

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 )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s