How to create and configure Search Service Application for SharePoint Foundation using PowerShell? Here is a solution.
Change in script:
Name of Server.
Name of Search Service Application.
To find name of Service Application Pool use next command Get-SPServiceApplicationPool.
You get one of next Service Appliction Pool:
"SharePoint Web Services System" "SharePoint Web Services Default"
Change Application Pool in script for $svcPool and $adminPool.
Script:
#Start the search service instance on the server
Get-SPEnterpriseSearchServiceInstance -Local | Start-SPEnterpriseSearchServiceInstance
$serverName="SAVA"
Start-SPEnterpriseSearchQueryAndSiteSettingsServiceInstance -Identity $serverName
#Give a unique name to your search service application
$serviceAppName = "Search Service Application"
#Get the application pools to use (make sure you change the value for your environment)
$svcPool = Get-SPServiceApplicationPool "SharePoint Web Services Default"
$adminPool = Get-SPServiceApplicationPool "SharePoint Web Services Default"
#Get the service from the service instance so we can call a method on it
$searchServiceInstance = Get-SPEnterpriseSearchServiceInstance –Local
$searchService = $searchServiceInstance.Service
#Define your unique DB names without the guids
$adminDB = "Search_Service_Application_DB"
$propertyStoreDB = "Search_Service_Application_PropertyStoreDB"
$crawlStoreDB = "Search_Service_Application_CrawlStoreDB"
$analysticsStoreDB = "Search_Service_Application_AnalyticsStoreDB"
$linkStoreDB = "Search_Service_Application_LinkStoreDB"
#Since this method takes in the value of object type Microsoft.SharePoint.Administration.SPDatabaseParameters we will
create these from our clean DB names
$adminDBParameters = [Microsoft.SharePoint.Administration.SPDatabaseParameters]::CreateParameters($adminDB,"None")
$propertyDBParameters = [Microsoft.SharePoint.Administration.SPDatabaseParameters]::CreateParameters
($propertyStoreDB,"None")
$crawlStoreDBParameters = [Microsoft.SharePoint.Administration.SPDatabaseParameters]::CreateParameters
($crawlStoreDB,"None")
$analyticsStoreDBParameters = [Microsoft.SharePoint.Administration.SPDatabaseParameters]::CreateParameters
($analysticsStoreDB,"None")
$linkStoreDBParameters = [Microsoft.SharePoint.Administration.SPDatabaseParameters]::CreateParameters($linkStoreDB,"None")
#Create the search service application by calling the function
$searchServiceApp = $searchService.CreateApplication($serviceAppName, $adminDBParameters, $propertyDBParameters,
$crawlStoreDBParameters, $analyticsStoreDBParameters, $linkStoreDBParameters,
[Microsoft.SharePoint.Administration.SPIisWebServiceApplicationPool]$svcPool,
[Microsoft.SharePoint.Administration.SPIisWebServiceApplicationPool]$adminPool)
#Create the search service application proxy as usual (luckily PowerShell for this works and is bot blocked)
$searchProxy = New-SPEnterpriseSearchServiceApplicationProxy -Name "$serviceAppName Proxy" -SearchApplication
$searchServiceApp
#Provision the search service application
$searchServiceApp.Provision()
At this point the search service application will be provisioned without any topology components. Active topology using next script.
#Now we will call the method to initiate the default topology component creation using reflection
$bindings = @("InvokeMethod", "NonPublic", "Instance")
$types = @([Microsoft.Office.Server.Search.Administration.SearchServiceInstance])
$values = @([Microsoft.Office.Server.Search.Administration.SearchServiceInstance]$searchServiceInstance)
$methodInfo = $searchServiceApp.GetType().GetMethod("InitDefaultTopology", $bindings, $null, $types, $null)
$searchTopology = $methodInfo.Invoke($searchServiceApp, $values)
Now you need some patience while all the components spring to life behind the scenes. This can take some time depending how robust your environment is.
Change in script:
Name of Server.
Name of Search Service Application.
To find name of Service Application Pool use next command Get-SPServiceApplicationPool.
You get one of next Service Appliction Pool:
"SharePoint Web Services System" "SharePoint Web Services Default"
Change Application Pool in script for $svcPool and $adminPool.
Script:
#Start the search service instance on the server
Get-SPEnterpriseSearchServiceInstance -Local | Start-SPEnterpriseSearchServiceInstance
$serverName="SAVA"
Start-SPEnterpriseSearchQueryAndSiteSettingsServiceInstance -Identity $serverName
#Give a unique name to your search service application
$serviceAppName = "Search Service Application"
#Get the application pools to use (make sure you change the value for your environment)
$svcPool = Get-SPServiceApplicationPool "SharePoint Web Services Default"
$adminPool = Get-SPServiceApplicationPool "SharePoint Web Services Default"
#Get the service from the service instance so we can call a method on it
$searchServiceInstance = Get-SPEnterpriseSearchServiceInstance –Local
$searchService = $searchServiceInstance.Service
#Define your unique DB names without the guids
$adminDB = "Search_Service_Application_DB"
$propertyStoreDB = "Search_Service_Application_PropertyStoreDB"
$crawlStoreDB = "Search_Service_Application_CrawlStoreDB"
$analysticsStoreDB = "Search_Service_Application_AnalyticsStoreDB"
$linkStoreDB = "Search_Service_Application_LinkStoreDB"
#Since this method takes in the value of object type Microsoft.SharePoint.Administration.SPDatabaseParameters we will
create these from our clean DB names
$adminDBParameters = [Microsoft.SharePoint.Administration.SPDatabaseParameters]::CreateParameters($adminDB,"None")
$propertyDBParameters = [Microsoft.SharePoint.Administration.SPDatabaseParameters]::CreateParameters
($propertyStoreDB,"None")
$crawlStoreDBParameters = [Microsoft.SharePoint.Administration.SPDatabaseParameters]::CreateParameters
($crawlStoreDB,"None")
$analyticsStoreDBParameters = [Microsoft.SharePoint.Administration.SPDatabaseParameters]::CreateParameters
($analysticsStoreDB,"None")
$linkStoreDBParameters = [Microsoft.SharePoint.Administration.SPDatabaseParameters]::CreateParameters($linkStoreDB,"None")
#Create the search service application by calling the function
$searchServiceApp = $searchService.CreateApplication($serviceAppName, $adminDBParameters, $propertyDBParameters,
$crawlStoreDBParameters, $analyticsStoreDBParameters, $linkStoreDBParameters,
[Microsoft.SharePoint.Administration.SPIisWebServiceApplicationPool]$svcPool,
[Microsoft.SharePoint.Administration.SPIisWebServiceApplicationPool]$adminPool)
#Create the search service application proxy as usual (luckily PowerShell for this works and is bot blocked)
$searchProxy = New-SPEnterpriseSearchServiceApplicationProxy -Name "$serviceAppName Proxy" -SearchApplication
$searchServiceApp
#Provision the search service application
$searchServiceApp.Provision()
At this point the search service application will be provisioned without any topology components. Active topology using next script.
#Now we will call the method to initiate the default topology component creation using reflection
$bindings = @("InvokeMethod", "NonPublic", "Instance")
$types = @([Microsoft.Office.Server.Search.Administration.SearchServiceInstance])
$values = @([Microsoft.Office.Server.Search.Administration.SearchServiceInstance]$searchServiceInstance)
$methodInfo = $searchServiceApp.GetType().GetMethod("InitDefaultTopology", $bindings, $null, $types, $null)
$searchTopology = $methodInfo.Invoke($searchServiceApp, $values)
Now you need some patience while all the components spring to life behind the scenes. This can take some time depending how robust your environment is.