SharePoint 2013 Search Center URL update in All Site Collections

When we plan to use a new search center in SharePoint 2013 for a web application, the question arises how to update the site collections with this new Search Center URL and PowerShell seemed the best option and while iterating through all the site collections to update Search Center URL. Make sure the search settings under subsites/webs “Use the same results page setting as my parent” is checked. Then updating the search center url at Site Collection level should work for all the sub sites.

$SPWebApp = Get-SPWebApplication
foreach ($SPSite in $SPWebApp.Sites)
if ($SPSite -ne $null)
$web = Get-SPWeb $spsite.Url
$web.AllProperties[“SRCH_SB_SET_SITE”] = ¬†‘{“Inherit”:false,”ResultsPageAddress”:”/sites/SearchCenter/Pages/results.aspx”,”ShowNavigation”:false}’
$web.AllProperties[“SRCH_ENH_FTR_URL_SITE”] = ‘/sites/SearchCenter/Pages’

In the above code make sure you update the full url of the search center if the web app is different for the search center other wise relative path should work.