3

I am running a remote powershell script which attempts to setup a web-application and site collection and then attempts to add a user to that site collection.

I receive the following error:

New-SPUser : Access is denied. (Exception from HRESULT: 0x80070005)

This does not occur if I run the same script locally with the same administrative account.

4

The answer is to run GrantAccessToProcessIdentity on your web-application

$webApp = Get-SPWebApplication -Identity <Identity>
$webApp.GrantAccessToProcessIdentity(<User>)
  • This is such a useful solution. I re-discover it second year in a row for the fifth time. I wish I would just remember. Thank you for posting it. – grisha Feb 12 '18 at 9:41

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.