Sharepoint 2013 – Configure Search with Power Shell

The following script will configure the Search Service and Components on a SharePoint 2013 Server:

$AppSearch = "SERVERNAME"

$SearchAppPoolName = "SharePoint_SearchApp"

$SearchAppPoolAccountName = "domain\username"

$SearchServiceName = "SharePoint_Search_Service"

$SearchServiceProxyName = "SharePoint_Search_Proxy"

$DatabaseName = "SharePoint_Search_AdminDB"

#Create a Search Service Application Pool

$spAppPool = New-SPServiceApplicationPool -Name $SearchAppPoolName -Account $SearchAppPoolAccountName -Verbose

#Start Search Service Instance on all Application Servers

Start-SPEnterpriseSearchServiceInstance $AppSearch -ErrorAction SilentlyContinue

Start-SPEnterpriseSearchQueryAndSiteSettingsServiceInstance $AppSearch  -ErrorAction SilentlyContinue

#Create Search Service Application

$ServiceApplication = New-SPEnterpriseSearchServiceApplication -Partitioned -Name $SearchServiceName -ApplicationPool $spAppPool.Name -DatabaseName $DatabaseName

#Create Search Service Proxy

New-SPEnterpriseSearchServiceApplicationProxy -Partitioned -Name $SearchServiceProxyName -SearchApplication $ServiceApplication

$clone = $ServiceApplication.ActiveTopology.Clone()

$AppSSI = Get-SPEnterpriseSearchServiceInstance -Identity $AppSearch

#Configure Search Components

New-SPEnterpriseSearchAdminComponent –SearchTopology $clone -SearchServiceInstance $AppSSI

New-SPEnterpriseSearchContentProcessingComponent –SearchTopology $clone -SearchServiceInstance $AppSSI

New-SPEnterpriseSearchAnalyticsProcessingComponent –SearchTopology $clone -SearchServiceInstance $AppSSI

New-SPEnterpriseSearchCrawlComponent –SearchTopology $clone -SearchServiceInstance $AppSSI

New-SPEnterpriseSearchQueryProcessingComponent –SearchTopology $clone -SearchServiceInstance $AppSSI

$PrimaryIndexLocation = "C:\Data"

$ReplicaIndexLocation = "D:\Data"

#We need two index partitions and replicas for each partition. Follow the sequence.

New-SPEnterpriseSearchIndexComponent –SearchTopology $clone -SearchServiceInstance $AppSSI -RootDirectory $PrimaryIndexLocation -IndexPartition 0

New-SPEnterpriseSearchIndexComponent –SearchTopology $clone -SearchServiceInstance $AppSSI -RootDirectory $ReplicaIndexLocation -IndexPartition 1


Tags: , ,

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: