Wednesday, September 23, 2015

Excluding Sites from Search - SharePoint 2013

Instead of setting each subsites search visibility property manually, use Powershell to exlude SharePoint sites from search.

Content from that site and all of its subsites will not appear in search results.


$siteUrl = "http://NameOfSite"

Get-SPSite $siteUrl | Get-SPWeb -Limit all | ForEach-Object {
Write-Host “`tProcessing Web: $($_.ServerRelativeUrl)…” -ForegroundColor White
 if (!$whatIf)
 {
 Write-Host “Setting properties on Web:” $_.Title -ForegroundColor White
 $_.NoCrawl = $true
 #Update the web
 $_.Update()
 }
 else
 {
 Write-Host “Reading properties on Web:” $_.Title -ForegroundColor White
 Write-Host “No crawl enabled: “$_.NoCrawl
 }
 }
 $site.Dispose()

No comments:

Post a Comment