Using PowerShell to deploy the Search Service App

But what about the Search databases?

by Agnes Molnar on 4/23/2014

Share this:

Article Details

Date Revised:

First of all, I have to admit, I owe a beer to both Todd and Spence for the script, I use the very same for deploying Search in SharePoint 2013:

# Get App Pool
$saAppPoolName = "SharePoint Service App Pool"
# Search Specifics, on single server farm
$searchServerName = (Get-ChildItem env:computername).value
$serviceAppName = "Demo Search Service Application"
$searchDBName = "DEMO_SearchService_DB"
# Grab the Appplication Pool for Service App
$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..."
$searchServiceApp = New-SPEnterpriseSearchServiceApplication -Name $serviceAppName -ApplicationPool $saAppPoolName -DatabaseName $searchDBName
$searchProxy = New-SPEnterpriseSearchServiceApplicationProxy -Name "$serviceAppName 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
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
Write-Host "Done!"

You might ask, "What about the Search database names?"

If you create your Search Service Application (SSA) on the Central Administration, there's no option for customizing the database names, and you'll end up with something like this (each ending with a GUID):


The problem with this is that it's not admin friendly at all. If you happen to have a SQL Server hosting the databases of more than one SharePoint farm, it will be a nightmare to figure out which database goes to which farm.

One option is to prefix the SSA's name with the farm/server's name, like "DEMO2013 Search Service App", as the database names are based on the SSA's name. If you give unique names to your SSAs on the different farms, you're one step closer to being able to recognize your databases.

In PowerShell above, you can see there's only one database name (see highlighted). Other databases (AnalyticsReportingStoreDB, CrawlStoreDB, LinksStoreDB) will take care of themselves, and will get the very same prefix as your SSA DB. And there're no GUID postfixes:


Topic: SharePoint and Office 365

Sign in with

Or register