Friday, July 15, 2011

Tips: How to set privileges for using PowerShell to manage SharePoint

We’ve already discussed that the Windows PowerShell doesn’t comprise SharePoint cmdlets. Instead, it has another feature that if you install SharePoint 2010, it will install the SharePoint 2010 Management Shell along with more than 500 SharePoint-specific cmdlets. It is a Windows PowerShell environment specifically for managing SharePoint.
If you wish to execute a command in the SharePoint 2010 Management Shell, it is required to open the file Management Shell on a SharePoint 2010 server. If you’re going to execute the commands, your user account should have the necessary privileges to the SharePoint object model and to the SharePoint databases. When you are working with SharePoint objects, connections to the database are generally created with the permissions of the current user.

For configuring a user’s privileges and security, you can use the SPShellAdmin. Let’s discuss here.

To list Shell administrators:
Get-SPShellAdmin


To add a user as a Shell administrator:
Add-SPShellAdmin -UserName -Database

For example, to allow user to execute commands against the PartnerNet site, use the following command:
Add-SPShellAdmin -UserName Contoso\
-Database (Get-SPContentDatabase -Identity PartnerNet_ContentDatabase)

Note that the Get-SPContentDatabase cmdlet and the PartnerNet content database name are used to retrieve the SPContentDatabase object.

To remove a user from Shell Admin:
Remove-SPShellAdmin -UserName -Database
You can start performing the above steps to check out.
B y , ,