Share via


Create SharePoint Service accounts through PowerShell script.

You need to domain admin or have permissions to create user in Active Directory.  Need to log in in the domain controller and run this script to create all the service accounts

It creates following service accounts

Account Description Domain rights
SP_Farm Farm account - Configure and manage the server farm. SecurityAdmin and DB_Creator rights on the SQL Instance
SP_admin Set up account runs SP Configuration wizard Local Administrator on all the SharePoint Servers. SecurityAdmin and DB_Creator rights on the SQL Instance
SP_Pool The Pool account is used to run the Web Application Pools None
SP_Services The Services Account is used to run the Service Application Pool None
SP_Crawl The Default Content Access Account for the Search Service Application None
SP_Search Service Account to run the SharePoint Search “Windows Service� None
SP_UserProfiles The User Profile Synchronization Account None
SP_MySitePool Used for the My Sites Web Application None
SP_CacheSuperUser Object Cache Service Account. The goals of the object cache are to reduce the load on the computer on which SQL Server is running, and to improve request latency and throughput. These user account must be properly configured to ensure that the object cache works correctly. SharePoint: Must be an account that has Full Control access to the Web application.
SP_CacheSuperReader Object Cache Service Account. The goals of the object cache are to reduce the load on the computer on which SQL Server is running, and to improve request latency and throughput. These user account must be properly configured to ensure that the object cache works correctly. SharePoint: Must be an account that has Full Read access to the Web application
WF_Service WorkFlow Manager Service Account Local Administrator and SysAdmin rights on the SQL instance.
SP_MySitePool Used for the My Sites Web Application None
SP_VisioUser Visio Unattended ID None
SP_ExcelUser Excel Unattended ID None
SP_PerfPointUser Performance Point Unattended ID None
SQL_Admin SQL Admin on the SQL Server. Used to Install the SQL Server. Local Administrator on the SQL Server
SQL_Services It is the service account for the following SQL Server services: MSSQLSERVER SQLSERVERAGENT None

 

$talespinDom= (get-addomain).distinguishedname
$password = "RiseAndShine@" | ConvertTo-SecureString -AsPlainText -Force

$ouNameSP = "Service Accounts"
$ouWithDom = "OU=$ounameSP,$talespindom"

#----------------------------> Create Organizational Unit <----------------------------

New-ADOrganizationalUnit -Name $OUNameSP -Path $talespinDom
Write-Host "OU $OUNameSP Created" -foregroundcolor green

#-----------------------------> SharePoint 2016 <-------------------------------

$usersArr = @("SP_Farm","SP_Admin","SP_AppPool","SP_SiteAdmin","SP_Service","SP_Crawl","SP_Search",
"SP_UserProfile","SP_PortalSuperReader","SP_CacheSuperUser",
"SP_PerfPointUser","WF_Service","SP_MySitePool","SP_PortalSuperUser","SQL_Admin","SQL_Service")

foreach ($user in $usersArr) {
$accountCreated=$null
$accountCreated = New-ADUser -Name $user -DisplayName $user -SamAccountName $user -AccountPassword $password -ChangePasswordAtLogon $false -PassThru -PasswordNeverExpires $true -Path $ouWithDom -Enabled $true
if($accountCreated){
Write-Host "$user Created" -foregroundcolor green}
else
{    Write-Host "$user not Created" -foregroundcolor red}
}