SharePoint: How to configure a SharePoint site as no “searchable” using PowerShell!

This time I’m sharing a PowerShell Script that allows to configure a SharePoint site (the script works for both SharePoint 2013 and 2016) as not searchable. You can download the script from the following Url: How to configure a SharePoint Site as not searchable

############################################################################################################################################

# Script that allows  to configure a Site as not searchable

# Required Parameters:

#   ->$sSiteUrl: Site Url.

############################################################################################################################################

 

If ((Get-PSSnapIn -Name Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue) -eq $null ) 

{ Add-PSSnapIn -Name Microsoft.SharePoint.PowerShell }

 

#We make a good usage of PowerShell in terms of performacne

$host.Runspace.ThreadOptions = "ReuseThread"

 

#Definition of the function that allows to configure a Site as not searchable

function Set-SiteAsNoSearchable

{

    param ($sSiteUrl)

    try

    {

        $spWeb=Get-SPWeb -Identity $sSiteUrl        

        Write-Host "Set $sSiteUrl as not searchable" -ForegroundColor Green

        $spWeb.NoCrawl=$True

        $spWeb.Update()

        $spWeb.Dispose()        

    }

    catch [System.Exception]

    {

        Write-Host -ForegroundColor Red $_.Exception.ToString()

    }

}

 

# Required Parameters

$sSiteUrl="http://<SharePoint_Site>"

Start-SPAssignment –Global

Set-SiteAsNoSearchable -sSiteUrl $sSiteUrl -sListName $sListName

Stop-SPAssignment –Global

Remove-PSSnapin Microsoft.SharePoint.PowerShell

Once you execute the script in PowerShell ISE or in Visual Studio you can check the result following bellow steps:

  • Browse the site settings page and under the Search section click Search and offline availability link.

image

  • In the related page, you will see that the configuration option for Indexing Site Content is checked as “No”.  In this way, once a new crawling is dome. this site will be excluded from the search index and it’s going to be not searchable.

image

Un pensamiento en “SharePoint: How to configure a SharePoint site as no “searchable” using PowerShell!

  1. Pingback: SharePoint & Office 365: Resumen de posts (XI)! | Pasión por la tecnología...

Responder

Introduce tus datos o haz clic en un icono para iniciar sesión:

Logo de WordPress.com

Estás comentando usando tu cuenta de WordPress.com. Cerrar sesión / Cambiar )

Imagen de Twitter

Estás comentando usando tu cuenta de Twitter. Cerrar sesión / Cambiar )

Foto de Facebook

Estás comentando usando tu cuenta de Facebook. Cerrar sesión / Cambiar )

Google+ photo

Estás comentando usando tu cuenta de Google+. Cerrar sesión / Cambiar )

Conectando a %s