Recently one of my customers, like many others, decided to migrate from SharePoint 2007 to SharePoint 2010. As with most other customers they wanted to take advantage of the new social capabilities. Specifically they wanted to utilize the new Enterprise Search capabilities with filtered search results and people search integration.
Let’s say you’ve migrated content databases from 2007 to 2010, and you previously had set up your enterprise search centers to http://servername/SearchCenter. However, when you migrated these they don’t have the new and improved search center functionality in 2010. So you create a new enterprise search center at http://servername/Search. All of your site collections will still have the old search center set to be used by sub-sites, but you can mass update this with PowerShell!
Thanks to a great article by Walter Munoz, there is a simple PowerShell script you can run to fix this. You can run this script using SharePoint Management Shell for each web application you’d like to update, and it will set a new Search Center for all site collections in the web application (note I’ve added in some comments with your options for the target results page, scopes drop down, etc):
# Site Collection Search Center URL
$searchURL = "/Search/Pages"
# Site Collection Search Dropdown Mode Codes:
#
# NO NEED TO SPECIFY SEARCH RESULTS PAGE
# HideScopeDD - Do Not Show Scopes Dropdown, and default to target results page
# ShowDD_NoContextual - Show, do not include contextual scopes
# ShowDD_NoContextual_DefaultURL - Show, do not include contextual scopes, and default to 's' URL parameter
#
# NEED TO SPECIFY SEARCH RESULTS PAGE
# HideScopeDD_DefaultContextual - Do Not Show Scopes Dropdown, and default to contextual scope
# ShowDD_DefaultContextual - Show and default to contextual scope
# ShowDD - Show scopes Dropdown
# ShowDD_DefaultURL - ShowDD_DefaultURL
#
$searchDDMode = "HideScopeDD"
# Site Collection Search Results Page
$searchResultsP = ""
# Get the Web Application
$webApplication = Get-SPWebApplication http://sharepoint
# loop through the sites in the web application
foreach ($site in $webApplication.Sites)
{
# Get the root web
$web = $site.RootWeb
# We want to update all sites that are not a search center
if ($web.WebTemplate -ne "SRCHCEN")
{
# Site Collection Search Center
$web.AllProperties["SRCH_ENH_FTR_URL"] = $searchURL
# Site Collection Search Dropdown Mode
$web.AllProperties["SRCH_SITE_DROPDOWN_MODE"] = $searchDDMode
# Site Collection Search Results Page - UNCOMMENT NEXT LINE IF USING ONE OF THE "Need to specify search results page" SEARCH MODES ABOVE
#$web.AllProperties["SRCH_TRAGET_RESULTS_PAGE"] = $searchResultsP
$web.Update()
Write-Host "Updated Search Settings on Site Collection: " $web.Url
}
}
You can download the PowerShell script here as a .txt file, just update to a .ps1 and set variables as well as your web application URL.
On a side note, if you’re not ready to upgrade to SharePoint 2010 yet but want to take advantage of some similar functionality take a look at the MOSS Faceted Search project on CodePlex. It gives you some advanced search refinements and such to enhance the experience before pulling the trigger on a big migration. Remember, always test in a test SharePoint farm first before production!







