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.

1 Answer 1

4

The answer is to run GrantAccessToProcessIdentity on your web-application

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.