Create and Extend SharePoint 2013 Search with PowerShell

Create the Search Service Application

In the first section of this article, I am going to show how you can create SharePoint 2013 Search Service Application Using PowerShell. This list of commands will allow you to name your own database, instead having a GUID based database name for search.

The architecture and design of search in SharePoint 2013 have changed a bit. There are more added components and more flexibility for high availability search farm, allowing the farm to index more than 100 million items.

There are several steps involved in the creation of a Search Service Application and defining the Search Topology. The steps are:

  1. Creating the Search Service Application
  2. Creating the Search Service Application Proxy
  3. Creating the Search Components
  4. Creating the Index

 

Instead of using Central Admin, I will be showing PowerShell commands to create SSA:

# Define the variables

$SSADB = “SharePoint_Demo_SearchAdmin”

$SSAName = “Search Service Application”

$SVCAcct = “mcm\sp_search”

$SSI = get-spenterprisesearchserviceinstance -local

 #1. Start the search services for SSI

Start-SPEnterpriseSearchServiceInstance -Identity $SSI

 #2. Create the Application Pool

$AppPool = new-SPServiceApplicationPool -name $SSAName”-AppPool” -account $SVCAcct

 #3. Create the search application and set it to a variable

$SearchApp = New-SPEnterpriseSearchServiceApplication -Name $SSAName -applicationpool $AppPool -databaseserver SQL2012 -databasename $SSADB

 #4. Create search service application proxy

$SSAProxy = new-SPEnterpriseSearchServiceApplicationProxy -name $SSAName” Application Proxy” -Uri $SearchApp.Uri.AbsoluteURI

 #5. Provision Search Admin Component

Set-SPEnterpriseSearchAdministrationComponent -searchapplication $SearchApp -searchserviceinstance $SSI

 #6. Create the topology

$Topology = New-SPEnterpriseSearchTopology -SearchApplication $SearchApp

 #7. Assign server(s) to the topology

$hostApp1 = Get-SPEnterpriseSearchServiceInstance -Identity “SPWFE”

New-SPEnterpriseSearchAdminComponent -SearchTopology $Topology -SearchServiceInstance $hostApp1

New-SPEnterpriseSearchCrawlComponent -SearchTopology $Topology -SearchServiceInstance $hostApp1

New-SPEnterpriseSearchContentProcessingComponent -SearchTopology $Topology -SearchServiceInstance $hostApp1

New-SPEnterpriseSearchAnalyticsProcessingComponent -SearchTopology $Topology -SearchServiceInstance $hostApp1

New-SPEnterpriseSearchQueryProcessingComponent -SearchTopology $Topology -SearchServiceInstance $hostApp1

New-SPEnterpriseSearchIndexComponent -SearchTopology $Topology -SearchServiceInstance $hostApp1 –IndexPartition 0

 #8. Create the topology

$Topology | Set-SPEnterpriseSearchTopology

 Extend the Search Service Application

Once SSA is created, we will need to clone the topology to be able to extend to other servers in the farm. In this script, we will be replicating all the Search components onto two servers in the farm, also creating 2 indexes. Here are the steps:

#1. Extend the Search Topology:

$hostApp1 = Get-SPEnterpriseSearchServiceInstance -Identity “AppSearch1”

$hostApp2 = Get-SPEnterpriseSearchServiceInstance -Identity “AppSearch2”

Start-SPEnterpriseSearchServiceInstance -Identity $hostApp1

Start-SPEnterpriseSearchServiceInstance -Identity $hostApp2

 

#3. Keep running this command until the Status is Online:

Get-SPEnterpriseSearchServiceInstance -Identity $hostApp1

Get-SPEnterpriseSearchServiceInstance -Identity $hostApp2

 #4. Once the status is online, you can proceed with the following commands:

$ssa = Get-SPEnterpriseSearchServiceApplication

$active = Get-SPEnterpriseSearchTopology -SearchApplication $ssa -Active

$newTopology = New-SPEnterpriseSearchTopology -SearchApplication $ssa

#Assign components to the hosts

New-SPEnterpriseSearchAdminComponent -SearchTopology $newTopology -SearchServiceInstance $hostApp1

New-SPEnterpriseSearchCrawlComponent -SearchTopology $newTopology -SearchServiceInstance $hostApp1

New-SPEnterpriseSearchContentProcessingComponent -SearchTopology $newTopology -SearchServiceInstance $hostApp1

New-SPEnterpriseSearchAnalyticsProcessingComponent -SearchTopology $newTopology -SearchServiceInstance $hostApp1

New-SPEnterpriseSearchQueryProcessingComponent -SearchTopology $newTopology -SearchServiceInstance $hostApp1

New-SPEnterpriseSearchIndexComponent -SearchTopology $newTopology -SearchServiceInstance $hostApp1 –IndexPartition 0

New-SPEnterpriseSearchAdminComponent -SearchTopology $newTopology -SearchServiceInstance $hostApp2

New-SPEnterpriseSearchCrawlComponent -SearchTopology $newTopology -SearchServiceInstance $hostApp2

New-SPEnterpriseSearchContentProcessingComponent -SearchTopology $newTopology -SearchServiceInstance $hostApp2

New-SPEnterpriseSearchAnalyticsProcessingComponent -SearchTopology $newTopology -SearchServiceInstance $hostApp2

New-SPEnterpriseSearchQueryProcessingComponent -SearchTopology $newTopology -SearchServiceInstance $hostApp2

#Below is creating another index on host 2. If you want to replicate the index to the second server, then you don’t need this step.

New-SPEnterpriseSearchIndexComponent -SearchTopology $newTopology -SearchServiceInstance $hostApp2 –IndexPartition 1

 #5. Activate the topology:

Set-SPEnterpriseSearchTopology -Identity $newTopology

 

The above scenario is creating a search topology over 2 server farm. For larger search topology, you can just add more hosts to the topology and select which components to run on them.

SharePoint 2013 Missing Patches – Configuration Wizard error

​I recently ran into some issues applying KBs on a SharePoint 2013 farm. My farm consists of 6 servers:

  1. 2 WFE servers;
  2. 2 Application servers (hosting Central Admin); and
  3. 2 Search servers

As usual, I installed all the KBs on all servers first, starting with the application server, then I started running the SharePoint Configuration Wizard on all the servers. The wizard successfully completed on the 2 Application Servers, but failed on the rest of the servers.

The error I was getting was:

“Error: Some farm products and patches were not detected on this or other servers. If products or patches are missing locally, you must quit this program and install the required products and patches on this server before starting this wizard. If products or patches are missing on your servers, you must install the required products and patches on the specific servers, and you may then click the Refresh button to perform the status check again.”

I have tried rebooting the servers and running the psconfig -cmd installcheck -noinstallcheck, but this did not help. I was getting the same error through the script. The farm thinks that the servers did not get the required KBs.

After further investigation, it turns out that the application registry on the servers needed to get refreshed. I ran the following PS command (as administrator):

Get-SPProduct –local

This will force a refresh of the server. You will need to run the command on all of the affected servers before you can run the configuration wizard again.