3

I'm trying to enable and configure output cache on a site collection with Powershell. But I get an Access denied when running the script.

Exception calling "Update" with "0" argument(s): "Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED))"

I'm running the following script and it fails on $cacheSettings.Update():

Add-PSSnapin Microsoft.SharePoint.Powershell -ErrorAction SilentlyContinue
$cacheSettings = new-object Microsoft.SharePoint.Publishing.SiteCacheSettingsWriter("http://siteaddress")
$cacheSettings.EnableCache
$cacheSettings.EnableCache = $true
$cacheSettings.Update()

I'm runing the script with a user that I thought had all the necessary permissions but obviously not. I gave the user permissions with the following command:

Get-SPDatabase | Add-SPShellAdmin mydomain\user

I executed the Add-SPShellAdmin-command with my install-account without any errors. mydomain\user is also site collection administrator for http://siteaddress.

So, what permission am I missing to run the script?

  • Does this user have either Site Collection Administrator on the site you're setting the value on, or FullControl rights on the Web Application? – Trevor Seward Feb 9 '16 at 15:24
  • why not run the script under your install account. – Waqas Sarwar MVP Feb 9 '16 at 15:45
  • I'm not running the script under my install account because I don't want to use it and want to have it disabled after recommendations from here: blog.lekman.com/2012/10/… "Will be disabled after install is completed." – GlennMmo Dec 23 '16 at 10:00
  • @TrevorSeward, I was convinced that I had Site Collection administrative rights, because an AD-group that I belong to was added to the "Site collection administrators" group. Now, several months later I came to realize that the AD-group added was the ADFS-claims-group. When I run scripts from the server I am running them as my windows claims-account. When I added the AD-group as windows claims-group in the Site collection administrators-group I was able to run the script. – GlennMmo Dec 23 '16 at 10:13
0

My problem was missing permissions on site collection administrative level. I had permission as site collection administrator when navigating from my local computer through adfs, i.e. with account c:0-.t|adfsfed|username@domain.com. But when running script from the server I'm running them as another user through integrated windows authentication, i.e. with account domain\username. I had to be site collection owner with the correct account to be able to run scripts towards the site collection. And I also needed permission through Add-SPShellAdmin.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.