Showing posts with label Search Service Application. Show all posts
Showing posts with label Search Service Application. Show all posts

Friday, June 4, 2021

Restore a search service application to another SharePoint farm

 The below script helps in restoring a search service application to another sharepoint farm. Before running below script, you need to take a back up of existing Search DB's ( with or without crawl db) to the new farms SQL server.

$saAppPoolName = "SearchService_AdminAppPool"

# Search Specifics, we are single server farm

$searchServerName = (Get-ChildItem env:computername).value

#Web Front End servers

$hostA = ""Server1"

$hostB = ""Server2"

#Servers hosting Search Components

$hostD = "Server1"

$hostE = "Server2" #In case of running components on multiple servers.

$IndexLocation = "F:\Apps\SearchIndex"

$serviceAppName = "Search Service Application"

$searchDBName = "Search Admin DB"

# Grab the Appplication Pool for Service Application Endpoint

$saAppPool = Get-SPServiceApplicationPool $saAppPoolName

# Start Search Service Instances

Write-Host "Starting Search Service Instances..."

#Start-SPEnterpriseSearchServiceInstance $searchServerName

#Start-SPEnterpriseSearchQueryAndSiteSettingsServiceInstance $searchServerName

# Create the Search Service Application and Proxy

Write-Host "Creating Search Service Application and Proxy..."

$searchInstance = Get-SPEnterpriseSearchServiceInstance -local

$searchServiceApp = Restore-SPEnterpriseSearchServiceApplication -Name $serviceAppName -ApplicationPool $saAppPoolName -AdminSearchServiceInstance $searchInstance -DatabaseName $searchDBName

$searchProxy = New-SPEnterpriseSearchServiceApplicationProxy -Name "Service Application and Proxy" -SearchApplication $searchServiceApp

# Clone the default Topology (which is empty) and create a new one and then activate it

Write-Host "Configuring Search Component Topology..."

$clone = $searchServiceApp.ActiveTopology.Clone()

#$searchServiceInstance = Get-SPEnterpriseSearchServiceInstance

$searchServiceInstance1 = Get-SPEnterpriseSearchServiceInstance -Identity $hostD

$searchServiceInstance2 = Get-SPEnterpriseSearchServiceInstance -Identity $hostE

#We need only two admin component

New-SPEnterpriseSearchAdminComponent -SearchTopology  $clone -SearchServiceInstance $searchServiceInstance1

New-SPEnterpriseSearchAdminComponent -SearchTopology  $clone -SearchServiceInstance $searchServiceInstance2

#We need two content processing components

New-SPEnterpriseSearchContentProcessingComponent -SearchTopology  $clone -SearchServiceInstance $searchServiceInstance1

#New-SPEnterpriseSearchContentProcessingComponent -SearchTopology $clone -SearchServiceInstance $searchServiceInstance2

#We need two analytics processing components

New-SPEnterpriseSearchAnalyticsProcessingComponent -SearchTopology  $clone -SearchServiceInstance $searchServiceInstance1

#New-SPEnterpriseSearchAnalyticsProcessingComponent -SearchTopology  $clone -SearchServiceInstance $searchServiceInstance2

#We need two crawl components

New-SPEnterpriseSearchCrawlComponent -SearchTopology  $clone -SearchServiceInstance $searchServiceInstance1

#New-SPEnterpriseSearchCrawlComponent -SearchTopology  $clone -SearchServiceInstance $searchServiceInstance2

#We need two query processing components

New-SPEnterpriseSearchQueryProcessingComponent -SearchTopology  $clone -SearchServiceInstance $searchServiceInstance1

New-SPEnterpriseSearchQueryProcessingComponent -SearchTopology  $clone -SearchServiceInstance $searchServiceInstance2

New-SPEnterpriseSearchIndexComponent -SearchTopology $clone -SearchServiceInstance $searchServiceInstance1 -RootDirectory $IndexLocation -IndexPartition 0

New-SPEnterpriseSearchIndexComponent -SearchTopology $clone -SearchServiceInstance $searchServiceInstance2 -RootDirectory $IndexLocation -IndexPartition 0

#New-SPEnterpriseSearchAdminComponent –SearchTopology $clone -SearchServiceInstance $searchServiceInstance

#New-SPEnterpriseSearchContentProcessingComponent –SearchTopology $clone -SearchServiceInstance $searchServiceInstance

#New-SPEnterpriseSearchAnalyticsProcessingComponent –SearchTopology $clone -SearchServiceInstance $searchServiceInstance

#New-SPEnterpriseSearchCrawlComponent –SearchTopology $clone -SearchServiceInstance $searchServiceInstance

#New-SPEnterpriseSearchIndexComponent –SearchTopology $clone -SearchServiceInstance $searchServiceInstance

#New-SPEnterpriseSearchQueryProcessingComponent –SearchTopology $clone -SearchServiceInstance $searchServiceInstance


Get-SPEnterpriseSearchTopology -SearchApplication $ssa

# Additional

$ssa = Get-SPEnterpriseSearchServiceApplication "Search Service Application" 

 $admin = Get-SPEnterpriseSearchAdministrationComponent -SearchApplication $ssa

 $admin | Set-SPEnterpriseSearchAdministrationComponent -SearchServiceInstance $searchServiceInstance1 -Force 

 $si = Get-SPEnterpriseSearchServiceInstance -Identity a007f95c-e67e-4150-ab8f-7fff8a71d5b6

$varSearchApp = get-spenterprisesearchserviceapplication

Set-SPEnterpriseSearchAdministrationComponent -SearchApplication $varSearchApp -SearchServiceInstance $si

Feel free to reply in case of any queries

Tuesday, January 15, 2019

SharePoint Server: "The search service is not able to connect to the machine that hosts the administration component"


The search service is not able to connect to the machine that hosts the administration component. Verify that the administration component ‘GUID’ in search application ‘Search Service Application’ is in a good state and try again
In Farm Search Administration page when you click on “Modify Topology” you get error “An unhandled exception occurred in the user interface.Exception Information: Exception has been thrown by the target of an”


Search is not able to connect is because of many reasons, In this article I am providing all possible causes and the solutions.


Solution 1

In the end it turns out to be that the application pool that hosts the search service application somehow doesn’t have the correct access.

You can simply change the application pool to use SharePoint Web Services System for search service applications and check.
1. Click on Start > Run > Type Inetmgr > Click OK0094 

  1. In IIS > Expand server > Expand sites > Expand “SharePoint Web Services”
  2. Now check all the GUID 1 by 1 in content view unless you find searchadmin.svc and searchservice.svc
  3. Right click GUID go to advance settings
  4. Change the application to “SharePoint Web Services” > Click OK

Solution 2

Enable the timer job and do IIS reset:
1. Run below PS command to know the status of timer job
Get-SPTimerJob job-application-server-admin-service
Result ==> Is Disabled: True
  1. Run below PS command to enable the service.
    Enable-SPTimerJob job-application-server-admin-service
    Result ==> IsDisabled: False
  2. Do Net Stop sptimerv4
  3. Do Net start sptimerv4
  4. Do iisreset

Solution 3

Ensure the account has full control permissions on the Search service application and IIS account used by this service application
Follow below steps
1. Open Central Admin  > Select Security > Select “Configure service accounts”

  1. Select the search service application
  2. For “select account for this component” Select a account which has full permission

SharePoint 2013 "The search service is not able to connect to the machine that hosts the administration component"


SharePoint Server: 

"The search service is not able to connect to the machine that hosts the administration component" after August 2018 CU


You need to check the EventViewer after installing August 2018 CU binaries and you can see there is a backward compatibility issue for the Search database if you are applying the patch directly after SP1.

EventViewer Log
"The synchronization operation of the search component: 5a44ee64-4c85-4c9e-a5f6-6098cf079cb1 associated to the search application: Search Service Application on server: DXXXXXV has failed. The component version is not compatible with the search database: SharePoint_Search_AdminDB_CrawlStore on server: DBPROD. The possible cause for this failure is The database schema version is less than the minimum backwards compatibility schema version that is supported for this component. To resolve this problem upgrade this database.."


Run the PSConfig and it will upgrade Search databases Schema and which will bring the search up and running.