I believe I got the base of this script from the AutoSPInstaller Project on CodePlex. I enhanced it to enable object cache on all web apps. Just fill in your variables on lines 1 and 2. *Note many of my customers tend to create long user names for these two accounts. Make sure to get the Pre-Compatibility 2000 username, its will be shoter in length than the full username. The script will blow up if you use the longer one. Thanks.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 | $SuperUserAcc = "domain\SPSObjectCacheF" $SuperReaderAcc = "domain\SPSObjectCacheR" $PortalName = Get-SPWebApplication | select DisplayName function Set-WebAppUserPolicy($webApp, $userName,$displayName, $perm) { [Microsoft.SharePoint.Administration.SPPolicyCollection]$policies = $webApp.Policies [Microsoft.SharePoint.Administration.SPPolicy]$policy = $policies.Add($userName, $displayName) [Microsoft.SharePoint.Administration.SPPolicyRole]$policyRole = $webApp.PolicyRoles | where {$_.Name -eq $perm} if ($policyRole -ne $null) { $policy.PolicyRoleBindings.Add($policyRole) } $webApp.Update() } function ConfigureObjectCache { foreach ($p in $PortalName) { $site = $p.DisplayName Try { Write-Host -ForegroundColor White "- Applying object cache..." $webapp = Get-SPWebApplication | ? {$_.DisplayName -eq $p.Displayname} If ($webapp -ne $Null) { Write-Host -ForegroundColor White " - Applying object cache to $site ..." $webapp.Properties["portalsuperuseraccount"] = $SuperUserAcc Set-WebAppUserPolicy $webApp $SuperUserAcc "Super User (Object Cache)" "Full Control" $webapp.Properties["portalsuperreaderaccount"] = $SuperReaderAcc Set-WebAppUserPolicy $webApp $SuperReaderAcc "Super Reader (Object Cache)" "Full Read" $webapp.Update() write-Host -ForegroundColor White "- Done." } } Catch { $_ Write-Warning "- An error occurred applying object cache to portal." } } } ConfigureObjectCache |




