Thursday, July 5, 2012

Search Settings Properties - PowerShell

This time, I’m going to shed some light on how to set the property values for the Search setting page.
I have a web-application and it is having many site collection with variation site to support for different languages. Each variation site is having its own content. When the user search from a particular variation site, the results should be shown inside the variation site itself. For that, If I set the Search results location at site collection level, that will be applied all across to the variation sites as well. In order to avoid that, we need to set the Site Collection Search Center value to Do not use custom scopes.

Search Settings Page


So my question is, how are you going to set that property for wsp deployment scenarios. When it comes to large level of projects with multiple site collection with variation sites, configuration are the pain points in the deployment process.
In order to automate and set the property values, I choose the PowerShell script.

The page is setting the values from the values stored in the Root web, property bag.

E.g:
In order to set the Site Collection Search Center value,

$web = Get-SPWeb –Identity http://server1/
$web.AllProperties[“SRCH_ENH_FTR_URL”] = “/en/SearchCenter/Pages”
$web.Update()


If you want to select the second radio button,

$web = Get-SPWeb –Identity http://server1/
$web.AllProperties[“SRCH_ENH_FTR_URL”] = $NULL
$web.Update()


If you want to select the second dropdown item, (Refer the table below for setting other values in that dropdown)

$web = Get-SPWeb –Identity http://server1/
$web.AllProperties[“SRCH_SITE_DROPDOWN_MODE”] = “HideScopeDD_DefaultContextual”
$web.Update()


If you want to set the search results page url,

$web = Get-SPWeb –Identity http://server1/
$web.AllProperties[“SRCH_TRAGET_RESULTS_PAGE”] = “/en/searchcenter/searchPages/”
$web.Update()



Key
Value
SRCH_ENH_FTR_URL
NULL or URL
SRCH_SITE_DROPDOWN_MODE
SRCH_TRAGET_RESULTS_PAGE
URL