Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

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.

share|improve this question
add comment

1 Answer

up vote 2 down vote accepted

The answer is to run GrantAccessToProcessIdentity on your web-application

$webApp = Get-SPWebApplication -Identity <Identity>
$webApp.GrantAccessToProcessIdentity(<User>)
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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