Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

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?

share|improve this question
add comment

2 Answers

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
share|improve this answer
add comment

A way to update all content databases.

$SourceDB = Get-SPContentDatabase CorrectDatabaseName
Get-SPWebApplication | ForEach {$_.ContentDatabases} | %{$_.SearchServiceInstance = $SourceDB.SearchServiceInstance; $_.Update()}
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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