Wednesday, January 15, 2014

create a new Farm Administrator via Power Shell

create a new Farm Administrator via Power Shell

Copy the below script and paste in noted pad as .PS1

Add-PSSnapin Microsoft.SharePoint.PowerShell -erroraction SilentlyContinue
# Creates a new Farm Administrator
$newFarmAdministrator = Read-Host -Prompt 'Please provide the name of the new Farm Administrator in the form of DOMAIN\Username'
$caWebApp = Get-SPWebApplication -IncludeCentralAdministration | where-object {$_.DisplayName -eq "SharePoint Central Administration v4"}
$caSite = $caWebApp.Sites[0]
$caWeb = $caSite.RootWeb

$farmAdministrators = $caWeb.SiteGroups["Farm Administrators"]
$farmAdministrators.AddUser($newFarmAdministrator, "", $newFarmAdministrator, "Configured via PowerShell")

$caWeb.Dispose()
$caSite.Dispose()

$caDB = Get-SPContentDatabase -WebApplication $caWebApp
Add-SPShellAdmin -Database $caDB -Username $newFarmAdministrator



Once copied as .PS1 run the script.


Note: The user must exist in AD before run the script.

Please Comment if you need Any Help.Your Feed back is always Welcome.I Am Happy to Help !!!!!

No comments:

Post a Comment

Your feedback is Much Appreciated. I will try to reply to your queries as soon as possible!!Anil Avula

ShareThis

X