Skip to content

Instantly share code, notes, and snippets.

@ishajain
Created March 30, 2014 23:30
Show Gist options
  • Select an option

  • Save ishajain/9881724 to your computer and use it in GitHub Desktop.

Select an option

Save ishajain/9881724 to your computer and use it in GitHub Desktop.
$Url = $(Read-Host -Prompt "Enter site url:")
if(-not(Get-PSSnapin | Where-Object {$_.Name -eq "Microsoft.SharePoint.PowerShell"})) {
Add-PSSnapin Microsoft.SharePoint.PowerShell;
}
$site = Get-SPSite $Url
Write-Host "Settings up search centre setup for your site" -ForegroundColor Yellow
$webs=$site.AllWebs | ? {$_.Url -like "*search*"}
$webs | % { Write-Host "Deleting old search centre" -ForegroundColor Yellow ; $_.Delete() }
Enable-SPFeature -Identity "BaseSite" -Url $site.Url
$searchSiteUrl= $site.Url+"/searchcentre"
New-SPWeb $searchSiteUrl -Name Search -Template SRCHCEN#0 -UseParentTopNav
Write-Host "Search centre is setup for your site successfully" -ForegroundColor Green
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment