Last active
August 29, 2015 14:06
-
-
Save sweeneyrobb/aa2ea87846f7ad303b5c to your computer and use it in GitHub Desktop.
Easy way to add a user as an administrator. Grants Farm Administrator rights along with ShellAdmin for Central Administration and a specified url.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$username = "{username}" | |
$webAppUrl = "{url}" | |
$centralAdmin = Get-SPWebApplication -IncludeCentralAdministration | ?{$_.DisplayName -eq "SharePoint Central Administration v4"} | |
$caWeb = Get-SPWeb -Identity $centralAdmin.Url | |
$farmAdministrators = $caWeb.SiteGroups["Farm Administrators"] | |
$farmAdministrators.AddUser($username, "", $username, "Configured via PowerShell") | |
$db = $centralAdmin.ContentDatabases[0] | |
Add-SPShellAdmin -UserName $username -database $db | |
Get-SPWebApplication $webAppUrl | Get-SPContentDatabase | ForEach-Object { | |
Add-SPShellAdmin -UserName $username -database $_ | |
} | |
Add-SPShellAdmin -UserName $username |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment