While adding a new user account to the shell admin role using powershell, the SharePoint management shell returned an error that the user already exist. Unfortunately the user didn’t had the correct role.
Before I got the error messaging I tried to give the user the shell admin role, while using the following command in the SharePoint Management Shell:
Add-SpShellAdmin -UserName domain\username
After running the Powershell command I got the following message in return:
“Cannot add [domain\user] to the SharePoint_Shell_Access role of the database [named sharepointdatabase]_Config. A possible cause of this error is that the account name was already added to the database as a login using a different user name than the account name.”
At line:1 char:1
+ Add-SpShellAdmin -UserName [domain\user]
+ CategoryInfo : InvalidData: (Microsoft.Share…AddSPShellAdmin:
SPCmdletAddSPShellAdmin) [Add-SPShellAdmin], ArgumentException
+ FullyQualifiedErrorId : Microsoft.SharePoint.PowerShell.SPCmdletAddSPShellAdmin
To solve this, I had to go my SQL server and open SQL Management Studio and checked the following:
Under Security Logins, right click the user account you are using (if it is not there then it doesn’t have the permissions) and choose properties. After that go to User Mappings and look for your Sharepoint_Config database. Here the account need to get the SharePoint_Shell_Access Role.