SharePoint Online: Hide Search Box in the Top Navigation Suite bar

Requirement: Hide Search Box in the Top Navigation Suite bar in SharePoint Online.

sharepoint online searchbox site navigation

How to Remove Search Box from Top Navigation Suite bar?

Search box in SharePoint Online top navigation suite bar can be hidden with this PowerShell script:

#Set Parameters
$SiteURL = ""

#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

    #Disable search in the navigation bar
    $Web.SearchBoxInNavBar = 3
Catch {
    write-host -f Red "Error:" $_.Exception.Message

SearchBoxInNavBar enumeration values:

  • Inherit = 0
  • AllPages = 1
  • ModernOnly = 2
  • Hidden = 3

We can also set search box settings using PnP PowerShell.

#Set Parameters
$SiteURL = ""

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

#Hide Searchbox in the Navigation bar
Set-PnPSearchSettings -SearchBoxInNavBar Hidden -Scope Web -Force

This hides the search box from top navigation bar of the SharePoint Online site in few minutes. To Enable the search box back in Navigation bar, use:

Set-PnPSearchSettings -SearchBoxInNavBar ModernOnly -Scope Web

Also, you can set the search box visibility at site collection level by changing the scope parameter from “Web” to “Site”

Salaudeen Rajack

Salaudeen Rajack is a SharePoint Architect with Two decades of SharePoint Experience. He loves sharing his knowledge and experiences with the SharePoint community, through his real-world articles!

Leave a Reply