Quantcast
Channel: Ryan Clark, Author at Mr. SharePoint
Viewing all articles
Browse latest Browse all 256

How to Hide SharePoint Search Box Using PnP PowerShell

$
0
0

Can you hide the search box?

In this guide, you will learn how to easily hide the search box in SharePoint using PnP PowerShell, and how to turn it back.

Let’s get started!

Benefits of Hiding the Search Box

Why bother hiding the search box?

Well, it can offer several benefits, such as:

  • Streamline the user interface
  • Reduce clutter
  • Focus the user’s attention on the content
  • Helpful for privacy

If you’re here, it’s likely that you want to limit what’s searchable for users on a certain site.

Since the search box is hidden, it can add an extra layer of control over how information is accessed.

How to Hide the Search Box in SharePoint

Fortunately, hiding the search box isn’t that complicated.

Hiding the search box

You can simply execute a command that sets a specific property of the site to hide the search box.

Here’s the PnP PowerShell script:

Connect-PnPOnline -Url YourSiteURL -Interactive
$web = Get-PnPWeb
$web.SearchBoxInNavBar = "Hidden"
$web.Update()
Invoke-PnPQuery

Easy, right?

Here’s the result:

hide search box in the sharepoint online site

No more search box. 🙂

Primary settings

So what controls the visibility and behavior of the search box?

You can check the script earlier, but it’s actually the SearchBoxInNavBar property.

Now, there are three primary settings that apply to the search box visibility:

  1. AllPages
  2. ModernOnly
  3. Hidden

When you set the search box settings to AllPages, the search bar will be visible on all pages within the site collection.

If ModernOnly, this will limit the visibility of the search box to only the modern pages of the site collection.

What we used earlier was Hidden and it will remove the search box from all pages across the site collection.

Note: Any of these settings don’t affect the search functionality of SharePoint Online. But naturally, you can’t search without the search bar. 😅

Displaying the Search Box

How do you turn it back?

From what I explained earlier, you can make the search box visible on all pages (modern and classic pages) like this:

$web = Get-PnPWeb
$web.SearchBoxInNavBar = "AllPages"
$web.Update()
Invoke-PnPQuery

If you do that, the search box will revert to its original setting, which is set to show on all pages in SharePoint.

But if you only want the search box to show up on SharePoint modern pages, use this script:

$web = Get-PnPWeb
$web.SearchBoxInNavBar = "ModernOnly"
$web.Update()
Invoke-PnPQuery

Nice! If you need the search box, you can turn it back now. 🙂

Got any more questions about hiding the search box in SharePoint Online? Just leave a comment below.

For any business-related questions or concerns, kindly reach out using the contact form here. I’ll reply asap. 🙂

The post How to Hide SharePoint Search Box Using PnP PowerShell appeared first on Mr. SharePoint.


Viewing all articles
Browse latest Browse all 256

Trending Articles