For a user to be able to use the SharePoint 2010 Management Shell, the user account must be granted the SharePoint_Shell_Access role (of a SharePoint content database) and be a member of the WSS_Admin_WPG group.

Attempting to run the Management Shell without these permission will result in the following error message;

The local farm is not accessible. Cmdlets with FeatureDependencyId are not registered.

The Add-SPShellAdmin powershell command can be used to grant this permission for an arbitrary user account, the command accepts a username in the DOMAIN\useraccount form and a reference to a content database.

Given that content databases can be widely dispersed, the following powershell script will set these permissions given a web application reference;

cls
add-pssnapin microsoft.sharepoint.powershell -ea SilentlyContinue

$accs = ("domain\user1","domain\user2","domain\user3")
(Get-SPContentDatabase -webapplication "http://mywebapp") | % {
    "Content Database: $($_.Id), $($_.Name)"
    $db = $_
    $accs | % {
        "`tAdding ShellAdmin rights for account: $_ to DB $($db.Name)"
        Add-SPShellAdmin -UserName $_ -database $db
    }
}

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.