Friday, February 21, 2014

Granting SharePoint PowerShell access to non-System accounts

When I run SharePoint PowerShell commands, I usually run them as the System account.

However, when dealing with SharePoint 2013, items such as SharePoint 2013 Workflows will not run under the System account, which means that I have to design and test my SharePoint 2013 Workflows under a different user account.

As part of my normal development process, I frequently need to run SharePoint PowerShell commands to execute and test various parts of functionality that I am developing.

However, while attempting to run a SharePoint PowerShell command under this different user account context, I suddenly encountered the following error message:

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

Thinking that I did not have enough privileges on the SharePoint Farm, I proceeded to grant that user account Farm Administrator privileges.

However, still no luck!  Same exact error message!!

Therefore, after doing a bit more digging, I discovered that I needed to specially grant rights to execute SharePoint PowerShell commands as described in this article: http://technet.microsoft.com/en-us/library/ee806878(v=office.14).aspx

I needed to grant SharePoint_Shell_Access privileges to my current user account by using the Add-SPShellAdmin PowerShell command: http://technet.microsoft.com/en-us/library/ff607596(v=office.15).aspx

Once I ran this command against my specific content database using a command similar to the following:

Get-SPDatabase | ?{$_.Name -eq "WSS_Content"} | Add-SPShellAdmin -Username CONTOSO\User1

I was then finally able to execute SharePoint PowerShell commands with my non-system SharePoint user account! Yeah!!



No comments:

Post a Comment