#Login to server with farm account# #============================================================== #Search Service Application Configuration Settings #============================================================== $SearchApplicationPoolName = "<SP2013_Search_Service>" $SearchApplicationPoolAccountName = "<Search Service acoount>" $SearchServiceApplicationName = "SP2013 Search Service" $SearchServiceApplicationProxyName = "SP2013 Search Service Proxy" $DatabaseServer = "<Database Instance name>" $DatabaseName = "SP2013_Search" #Confirm permission given on SQL Search instance #Create search index folder on each server where your are configuring index partition $IndexLocation<SERVER2> = "I:\SearchIndex<SERVER2>" $IndexLocation<SERVER1> = "I:\SearchIndex<SERVER1>" #============================================================== #Start Search Service Instance on <SERVER2> #============================================================== $SearchServiceInstance<SERVER2> = Get-SPEnterpriseSearchServiceInstance -local Write-Host -ForegroundColor DarkGray "Checking if SSI is Online on <SERVER2>" if($SearchServiceInstance<SERVER2>.Status -ne "Online") { Write-Host -ForegroundColor Yellow "Starting Search Service Instance" Start-SPEnterpriseSearchServiceInstance -Identity $SearchServiceInstance<SERVER2> While ($SearchServiceInstance<SERVER2>.Status -ne "Online") { Start-Sleep -s 5 } Write-Host -ForegroundColor Yellow "SSI on <SERVER2> is started" } #============================================================== #Start Search Service Instance on <SERVER1> #============================================================== $SearchServiceInstance<SERVER1> = Get-SPEnterpriseSearchServiceInstance -Identity "<SERVER1>" Write-Host -ForegroundColor DarkGray "Checking if SSI is Online on <SERVER1>" if($SearchServiceInstance<SERVER1>.Status -ne "Online") { Write-Host -ForegroundColor Yellow "Starting Search Service Instance" Start-SPEnterpriseSearchServiceInstance -Identity $SearchServiceInstance<SERVER1> While ($SearchServiceInstance<SERVER1>.Status -ne "Online") { Start-Sleep -s 5 } Write-Host -ForegroundColor Yellow "SSI on <SERVER1> is started" } #============================================================== #Search Application Pool #============================================================== Write-Host -ForegroundColor DarkGray "Checking if Search Application Pool exists" $SPServiceApplicationPool = Get-SPServiceApplicationPool -Identity $SearchApplicationPoolName -ErrorAction SilentlyContinue if (!$SPServiceApplicationPool) { Write-Host -ForegroundColor Yellow "Creating Search Application Pool" $SPServiceApplicationPool = New-SPServiceApplicationPool -Name $SearchApplicationPoolName -Account $SearchApplicationPoolAccountName -Verbose } #============================================================== #Search Service Application #============================================================== Write-Host -ForegroundColor DarkGray "Checking if SSA exists" $SearchServiceApplication = Get-SPEnterpriseSearchServiceApplication -Identity $SearchServiceApplicationName -ErrorAction SilentlyContinue if (!$SearchServiceApplication) { Write-Host -ForegroundColor Yellow "Creating Search Service Application" $SearchServiceApplication = New-SPEnterpriseSearchServiceApplication -Name $SearchServiceApplicationName -ApplicationPool $SPServiceApplicationPool.Name -DatabaseServer $DatabaseServer -DatabaseName $DatabaseName } Write-Host -ForegroundColor DarkGray "Checking if SSA Proxy exists" $SearchServiceApplicationProxy = Get-SPEnterpriseSearchServiceApplicationProxy -Identity $SearchServiceApplicationProxyName -ErrorAction SilentlyContinue if (!$SearchServiceApplicationProxy) { Write-Host -ForegroundColor Yellow "Creating SSA Proxy" New-SPEnterpriseSearchServiceApplicationProxy -Name $SearchServiceApplicationProxyName -SearchApplication $SearchServiceApplicationName } # <SERVER2> is the local server where the script is run. #============================================================== #Cannot make changes to topology in Active State. #Create new topology to add components #============================================================== $InitialSearchTopology = $SearchServiceApplication | Get-SPEnterpriseSearchTopology -Active $NewSearchTopology = New-SPEnterpriseSearchTopology -SearchApplication $SearchServiceApplication #============================================================== #Search Service Application Components on <SERVER2> #Creating all components except Index (created later) #============================================================== New-SPEnterpriseSearchAnalyticsProcessingComponent -SearchTopology $NewSearchTopology -SearchServiceInstance $SearchServiceInstance<SERVER2> New-SPEnterpriseSearchContentProcessingComponent -SearchTopology $NewSearchTopology -SearchServiceInstance $SearchServiceInstance<SERVER2> New-SPEnterpriseSearchQueryProcessingComponent -SearchTopology $NewSearchTopology -SearchServiceInstance $SearchServiceInstance<SERVER2> New-SPEnterpriseSearchCrawlComponent -SearchTopology $NewSearchTopology -SearchServiceInstance $SearchServiceInstance<SERVER2> New-SPEnterpriseSearchAdminComponent -SearchTopology $NewSearchTopology -SearchServiceInstance $SearchServiceInstance<SERVER2> #============================================================== #Search Service Application Components on <SERVER1>. #Crawl, Query, and CPC #============================================================== New-SPEnterpriseSearchContentProcessingComponent -SearchTopology $NewSearchTopology -SearchServiceInstance $SearchServiceInstance<SERVER1> New-SPEnterpriseSearchQueryProcessingComponent -SearchTopology $NewSearchTopology -SearchServiceInstance $SearchServiceInstance<SERVER1> New-SPEnterpriseSearchCrawlComponent -SearchTopology $NewSearchTopology -SearchServiceInstance $SearchServiceInstance<SERVER1> #============================================================== #Index Components with replicas #============================================================== New-SPEnterpriseSearchIndexComponent -SearchTopology $NewSearchTopology -SearchServiceInstance $SearchServiceInstance<SERVER2> -IndexPartition 0 -RootDirectory $IndexLocation<SERVER2> New-SPEnterpriseSearchIndexComponent -SearchTopology $NewSearchTopology -SearchServiceInstance $SearchServiceInstance<SERVER2> -IndexPartition 1 -RootDirectory $IndexLocation<SERVER2> #============================================================== #Setting Search Topology using Set-SPEnterpriseSearchTopology #============================================================== Set-SPEnterpriseSearchTopology -Identity $NewSearchTopology #============================================================== #Clean-Up Operation #============================================================== Write-Host -ForegroundColor DarkGray "Deleting old topology" Remove-SPEnterpriseSearchTopology -Identity $InitialSearchTopology -Confirm:$false Write-Host -ForegroundColor Yellow "Old topology deleted" #============================================================== #Check Search Topology #============================================================== Get-SPEnterpriseSearchStatus -SearchApplication $SearchServiceApplication -Text Write-Host -ForegroundColor Yellow "Search Service Application and Topology is configured!!" #============================================================================================================================================================================ # Please run the below command on other Search index server where you want to create replica of index partitions; this is another server where you are running search service. #================================================================================================================================================================================ $IndexLocation<SERVER1> = "I:\SearchIndex<SERVER1>" $newssi = Get-SPEnterpriseSearchServiceInstance -Identity "Local" # Clone the existing topology: $ssa = Get-SPEnterpriseSearchServiceApplication $activeTopology=Get-SPEnterpriseSearchTopology -Active -SearchApplication $ssa $newTopology = New-SPEnterpriseSearchTopology -SearchTopology $activeTopology -SearchApplication $ssa -Clone # Add a new index component and specify it is associated with the new index partition 1: New-SPEnterpriseSearchIndexComponent -SearchTopology $newTopology -SearchServiceInstance $newssi -IndexPartition 1 -RootDirectory $IndexLocation<SERVER1> New-SPEnterpriseSearchIndexComponent -SearchTopology $newTopology -SearchServiceInstance $newssi -IndexPartition 0 -RootDirectory $IndexLocation<SERVER1> Set-SPEnterpriseSearchTopology -Identity $newTopology