SharePoint 2019 Create Search Service Application with Powershell

Powershell Script

In SharePoint you can create a Search Service Application by using PowerShell. If you didn’t create it with AutoSPInstaller or if you want to configure it later on, you should use Powershell for one reason. If you use the GUI in Central Administration, it will create the databases with a GUID in its name.

Powershell Script

So here i like to share the script to create the search service application which i used in a Testing Environment in SharePoint 2019.

Add-PSSnapin Microsoft.SharePoint.PowerShell -erroraction SilentlyContinue
# Name Application Pool 
$SearchAppPoolName = "Search Service App Pool"    
# Names for SA and DB's 
$serviceAppName = "Search Service Application" 
$searchDBName = "SP19_SearchService" 
$SearchAppPoolAccountName = "domain\sp_search"
# Application Pool for Search SA 
$AppPool = New-SPServiceApplicationPool -Name "Search Service App Pool" -Account $SearchAppPoolAccountName
$AppPool = Get-SPServiceApplicationPool $SearchAppPoolName

# Start Search Service Instances 
Get-SPEnterpriseSearchServiceInstance -Local | Start-SPEnterpriseSearchServiceInstance 
Get-SPEnterpriseSearchQueryAndSiteSettingsServiceInstance -Local | Start-SPEnterpriseSearchQueryAndSiteSettingsServiceInstance

$sa = New-SPEnterpriseSearchServiceApplication -Name $serviceAppName -DatabaseName $searchDBName –ApplicationPool  $AppPool
New-SPEnterpriseSearchServiceApplicationProxy -Name "Search Service Application Proxy" -SearchApplication $sa

#See if it's working
Get-SPEnterpriseSearchServiceInstance -local

#Clone topology 
$clone = $sa.ActiveTopology.Clone() 
#Create new topology 
$searchServiceInst = Get-SPEnterpriseSearchServiceInstance -local
New-SPEnterpriseSearchAdminComponent -SearchTopology $clone -SearchServiceInstance $searchServiceInst
New-SPEnterpriseSearchContentProcessingComponent -SearchTopology $clone -SearchServiceInstance $searchServiceInst
New-SPEnterpriseSearchAnalyticsProcessingComponent -SearchTopology $clone -SearchServiceInstance $searchServiceInst
New-SPEnterpriseSearchCrawlComponent -SearchTopology $clone -SearchServiceInstance $searchServiceInst
New-SPEnterpriseSearchIndexComponent -SearchTopology $clone -SearchServiceInstance $searchServiceInst -IndexPartition 0 -RootDirectory D:\Index\
New-SPEnterpriseSearchQueryProcessingComponent -SearchTopology $clone -SearchServiceInstance $searchServiceInst
#Activate new topology 
$clone.Activate()

After this your Search Service should be running. Now it is time to care about the following steps:

  • Add a search crawl account
  • Add a search center site collection
  • Add and configure your Content Sources

Hope it helps you. If you like to read more about SharePoint Search in 2019 i can recommend you the following articles:
What’s new in search
What’s new in SharePoint 2019

The article or information provided here represents completely my own personal view & thought. It is recommended to test the content or scripts of the site in the lab, before making use in the production environment & use it completely at your own risk. The articles, scripts, suggestions or tricks published on the site are provided AS-IS with no warranties or guarantees and confers no rights.



Karsten Schneider
About Karsten Schneider 295 Articles
He is Consultant for SharePoint Solutions for collaboration, communication and business processes. He provides his customers applications based on standard features as well as development or combining the power of several microsoft tools like Dynamics CRM. In his free time he tries to collect tipps and worthy experience in this blog.

Be the first to comment

Leave a Reply

Your email address will not be published.


*