12/21/2012
Date:
3:53:00 AM
Posted By
SharePoint
In order to use Windows PowerShell for SharePoint 2010 Products, a user must be a member of the SharePoint_Shell_Access, and you can do that via Add-SPShellAdmin cmdlet. However if user needs to work with a lot of content databases then you need to repeat this procedure over and over. Here is a simple script that will add a user to the SharePoint_Shell_Access role for all content databases.
1 | if((Get-PSSnapin | Where {$_.Name -eq "Microsoft.SharePoint.PowerShell"}) -eq $null) { |
2 | Add-PSSnapin Microsoft.SharePoint.PowerShell; |
5 | $username = Read-Host "Enter username"; |
6 | Get-SPContentDatabase | ForEach-Object {Add-SPShellAdmin -UserName $username -database $_.Id} |