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.

1 Answer 1


The answer is to run GrantAccessToProcessIdentity on your web-application

$webApp = Get-SPWebApplication -Identity <Identity>
  • 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
    Commented Feb 12, 2018 at 9:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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