Create the Search Service Application in SharePoint Server using PowerShell

One of the most important service application (in my opinion), and maybe one of the most complex as well, is the Search Service Application.
We can be flexible, and put some of the components of multiple servers, or host everything in a single server.

For information about the different Search components in SharePoint Server, have a look at the Overview of Search architecture in SharePoint Server.

When configured properly, it is a very powerful (and one of the main) feature of SharePoint.

In this blog post, we will configure the Search Service Application for a single-server farm by hosting all components on the same server.


So… What will the script do?

  1. First, we will declare a few variables to use later,
  2. Then we’ll start the Search service instances like we used to do in SharePoint Server 2013,
  3. Now it’s time to create the Search Service Application & Proxy,
  4. To finish, we’ll clone the default topology & activate it!

Let’s get started! 🙂


Declare variables

We need to know the Application Pool to use, the name we’ll give to the Search SA, and also choose a name for the Search Service database(s) (this will also be the prefix for the 4 databases!)

  • Application Pool => DefaultAppPool
  • Name for Search SA => Search Service Application
  • Databases’ names (prefix) => SP2016_Search_SA_DB


# Get Application Pool 
$SearchAppPoolName = "DefaultAppPool"   ### TO CHANGE WITH YOUR APP POOL NAME ### 

# Names for SA and DB's 
$serviceAppName = "Search Service Application" $searchDBName = "SP2016_Search_SA_DB" 

# Application Pool for Search SA 
$AppPool = Get-SPServiceApplicationPool $SearchAppPoolName


Start the Search service instances

Like in SharePoint 2013, we need to start the service instances for the application to be created smoothly.

# Start Search Service Instances 
Get-SPEnterpriseSearchServiceInstance -Local | Start-SPEnterpriseSearchServiceInstance 
Get-SPEnterpriseSearchQueryAndSiteSettingsServiceInstance -Local | Start-SPEnterpriseSearchQueryAndSiteSettingsServiceInstance


Create Search SA and Proxy

Now’s the time to create the Search Service Application, as well as the Proxy.

# Create the Search SA & Proxy 
$searchServiceApp = New-SPEnterpriseSearchServiceApplication -Name $serviceAppName -ApplicationPool $SearchAppPoolName -DatabaseName $searchDBName 
$searchProxy = New-SPEnterpriseSearchServiceApplicationProxy -Name "$serviceAppName Proxy" -SearchApplication $searchServiceApp

Clone the topology and Create a new one (+activation)

#Clone topology 
$clone = $searchServiceApp.ActiveTopology.Clone() 

#Create new topology 
$searchServiceInst = Get-SPEnterpriseSearchServiceInstance 
New-SPEnterpriseSearchAdminComponent –SearchTopology $clone -SearchServiceInstance $searchServiceInst 
New-SPEnterpriseSearchContentProcessingComponent –SearchTopology $clone -SearchServiceInstance $searchServiceInst 
New-SPEnterpriseSearchAnalyticsProcessingComponent –SearchTopology $clone -SearchServiceInstance $searchServiceInst 
New-SPEnterpriseSearchCrawlComponent –SearchTopology $clone -SearchServiceInstance $searchServiceInst 
New-SPEnterpriseSearchIndexComponent –SearchTopology $clone -SearchServiceInstance $searchServiceInst 
New-SPEnterpriseSearchQueryProcessingComponent –SearchTopology $clone -SearchServiceInstance $searchServiceInst 

#Activate new topology 



Check the Search SA in SharePoint Server

Assuming all went well when running the script, we should end up with this! All green 🙂


Search Service Application created in SharePoint



Topology created



Change the “Default Content Access” account

By default, you’ll notice that the default content access account is set to the Farm account.
We need to change that to a specific crawl account (recommended).

  • Click on the <domain\farmAcct> link
  • Enter the Crawl account’s credentials
  • Click “OK

The crawl account is now changed.


Crawl Account changed


Next steps

Configure your crawls, rules, check the crawl logs, etc… !



Comments are closed.

%d bloggers like this: