SharePoint Online: Change Default Search Scope from “Search This Site” to “Search All Sites”

Requirement: Configure Search Scope in SharePoint Online site.

How to Change the Default Search Scope in SharePoint Online?

The default search scope in SharePoint Online is “Search this site”, which allows us to search inside the specific site collection. At times, you may want to change the search scope from Search This Site to Search all sites. This can be useful if you want to search all of your site collections, or if you want to search for content outside your site collection. In this article, we’ll show you how to change the search scope in SharePoint Online.

sharepoint online set search scope

PowerShell to Configure Search Scope in SharePoint Online

We can change the default search scope in SharePoint Online using the PowerShell script:

#Set Parameters
$SiteURL = "https://crescent.sharepoint.com/sites/Marketing"

#Get Credentials to connect
$Cred = Get-Credential

Try {
    #Setup the context
    $Ctx = New-Object Microsoft.SharePoint.Client.ClientContext($SiteURL)
    $Ctx.Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($Cred.UserName,$Cred.Password)
 
    #Get Web object
    $Web = $Ctx.Web
    $Ctx.Load($Web)
    $Ctx.ExecuteQuery()

    #Set search scope for the web to global
    $Web.SearchScope = 1
    $web.Update()
    $Ctx.ExecuteQuery()
}
Catch {
    write-host -f Red "Error:" $_.Exception.Message
}

This changes the search scope for a given SharePoint Online site from “Search this site” to “Search in SharePoint” (Global search).

sharepoint online change default search scope

Search scope enumeration values:

  • DefaultScope = 0
  • Tenant = 1
  • Hub = 2
  • Site = 3

Configure search scope in SharePoint Online using PnP PowerShell

We can also set the search scope using PnP PowerShell.

#Set Parameters
$SiteURL = "https://crescent.sharepoint.com/sites/Marketing"

#Connect to SharePoint Online site
Connect-PnPOnline -Url $SiteURL -Interactive

#change default search scope
Set-PnPSearchSettings -SearchScope Tenant

This will change the search scope from a local site to a global search. If you want to update multiple site collections, you can either loop through them and apply these settings or use a CSV file to change search scopes selectively.

Salaudeen Rajack

Salaudeen Rajack - SharePoint Expert with Two decades of SharePoint Experience. Love to Share my knowledge and experience with the SharePoint community, through real-time articles!

2 thoughts on “SharePoint Online: Change Default Search Scope from “Search This Site” to “Search All Sites”

  • Hello, is there a solution to do this in an on premise installation too (SharePoint 2019 Server)

    Reply
  • I did the above procedure but the problem is Scroll is now disabled on search page after changing the scope to global.

    Reply

Leave a Reply

Your email address will not be published. Required fields are marked *