Is there a way to assign a SharePoint Foundation search server to a content database using PowerShell, either while creating an Sp-WebApplication using New-SpWebApplication or by updating an SpWebApplication?

2 Answers 2


It's not possible to set this property at the web application level per se, as it is a per-database property. However, it is quite easy to set this property on a per-database level for an entire web application (With the only difference being that all new databases will not automatically have this setting).

To do this, you first need to find a database that has this search server already set. For example:

$SourceDB = Get-SPContentDatabase CorrectDatabaseName

Where "CorrectDatabaseName" is the name of the database that has this property already set.

What you now need to do is iterate over all databases in the destination web application, and set the SearchServiceInstance property to be the same as the correct DB. You can do this like this:

Get-SPContentDatabase -WebApplication WebAppNameOrUrl |%{$_.SearchServiceInstance = $SourceDB.SearchServiceInstance; $_.Update()}

where "WebAppNameOrUrl" is either the friendly name or the URL of the web application you wish to apply this property to. Alternatively, you could create your SPServiceInstance object another way, but i've found this to be the easiest way by far.

You can double-check to ensure that this property has been set on all the content databases by using the following:

Get-SPContentDatabase -WebApplication WebAppNameOrUrl | Select Name, SearchServiceInstance

A way to update all content databases.

$SourceDB = Get-SPContentDatabase CorrectDatabaseName
Get-SPWebApplication | ForEach {$_.ContentDatabases} | %{$_.SearchServiceInstance = $SourceDB.SearchServiceInstance; $_.Update()}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.