Forum Discussion

Kerem Yuceturk's avatar
Apr 12, 2019

Configure modern search results to search all of your organization (rather than the current site)

Hey everyone,

 

We heard from many of you the need to be able to change the scope of your modern search results pages. When you create a new communication site or team site in SharePoint Online today, and type into the search box, you are taken to the modern search results page. This page shows results from your current site by default, and allows you to expand the scope of your search to the hub that the current site is associated with (if there is one), or to the whole organization.

 

But there is a desire for being able to change the behavior to always search over the whole organization, or across the hub a site is associated with, without needing an additional click, especially if the site in question will be used as a modern landing page for your organization. 

Searching in a site will show results from that site (Strategy and Planning), with a control to expand the search scope to the hub (Sales) or the whole organization

I'm happy to say that with the latest version of the SharePoint PnP PowerShell extensions, it is possible to run a simple command as the site owner, and make your site use the organization, or the hub scope by default.

 

To change this setting:

1. Start PowerShell in administrator mode as you will be installing the PnP extensions.

2. Run the following commands to in this order:

PS C:\WINDOWS\system32> Install-Module SharePointPnPPowerShellOnline
# If you previously had installed this module, you may need to use the "-Force" parameter to install the newer version.
PS C:\WINDOWS\system32> Connect-PnPOnline -Url https://contosodemosg.sharepoint.com/sites/Strategy -UseWebLogin
# this will prompt you to sign into your site. Use the site owner credentials to sign in
PS C:\WINDOWS\system32> $web = Get-PnPWeb PS C:\WINDOWS\system32> $web.SearchScope = 1
# 1 for Tenant, 2 for Hub, 3 for Site, 0 for default behavior
PS C:\WINDOWS\system32> $web.Update() PS C:\WINDOWS\system32> Invoke-PnPQuery

After running these commands, the site will start to show results from the whole organization.After the change, results from the whole organization are displayed.To go back to the default setting, run the commands again with the value provided to "SearchScope" parameter to 0. 

 

To search across the Hub, use 2 as the SearchScope value.

 

We will be providing a way to set this setting using the UI in a future release as well.
Updated in April 2020 to reflect the ability to search across Hubs.

  • Hi Rick DeFoe, we are actually working on making that happen. We hope that will be coming in the next couple of months.

Resources