Sharepoint - Sharepoint 2010 powershell add-spsolution access denied

To add solutions you need to be local administrator on top of shell admin. Run the shell as administrator.

Edit:

As I said in comments, I can't find a specific requirement specified on TechNet, but I did a test on one of my farms:

  • First I added a brand new user to my AD.
  • As being member of the AD the users only right on my farm server is that its part of domain users, and hence part of local User group.
  • I fired up a SP2010 administration shell using Run as different user (right click on shell) and logged in as my new user. Already as I started up I got some errors because of lack of access (The local farm is not accessible. Cmdlets with FeatureDependencyId are not registered.)
  • I tried adding solution and got:

    Add-SPSolution : Cannot access the local farm. Verify that the local farm is properly configured, currently available, and that you have the appropriate permissions to access the database before trying again.

  • I now gave test user farm admin privileges and started up a new shell. Still got the same error.

  • I ran another Shell as my farm admin (if logged in as account remember to use Run As Administrator if you have UAC enabled). Here I added my test user as Shell Admin
  • I now started a new shell with my test user. No errors while loading, but when I tried adding I got the same error as you:

    Add-SPSolution: Access Denied

  • I then added the test user to the local administrator group and opened up a new shell.

  • When adding the user I could add the user without issues.


Per my own blog, if you’re encountering the following error, when trying to run a powershell script, you may not have sufficient permissions on the database.

Get-SPWeb : Cannot access the local farm. Verify that the local farm is properly configured, currently available, and that you have the appropriate permission to access the database before trying again.

The issue can be remedied with a few quick powershell commands.

Perform the following script in the SharePoint Management Shell, as a farm administrator and it will remove the error.

Get-SPDatabase | Add-SPShellAdmin SomeDomain\SomeUserName

This will grant the user both access to the configuration database as well as the content database.

Alternatively, you can revoke that granted access with the opposite command.

Get-SPDatabase | Remove-SPShellAdmin SomeDomain\SomeUserName

Tags:

Powershell