If you have a PowerShell script which should run on a SharePoint Server (Snap In: Microsoft.SharePoint.PowerShell), you have to run it with the credentials of a SP-Shell Admin.
The error message looks like this if the account is not a SP-Shell Admin:
To add the account to the SP-Shell Admin you have to login with an existing SP-Shell Admin. You can get all admins by following command:
After that, start a new PowerShell console with the “Run as administrator” command. If you don’t do this, your command will end with following error message:
Now we are ready to add a new shell admin but there is at least one more obstacle. You have to provide the database as an object. Otherwise, it won’t take effect. I’ve prepared a short script for this:
Copyright © 2015 easyguet.ch