Introduction
This blog will help to remove the Microsoft365 search bar or enable the Microsoft365 search bar in SharePoint online.
To connect the SharePoint Online site in Powershell, run the below command:
- Connect-PnPOnline -Url "Enter Site URL" -UseWebLogin
Remove Microsoft365 Search bar in SharePoint Online site
Run the below command to remove the Microsoft365 search bar in the current site, which can only affect the changes in the current SharePoint Online site.
- Set-PnPSearchSettings -SearchBoxInNavBar Hidden -Scope Web
Run the below command to remove the Microsoft365 search bar in the Site Collection and its respected subsites.
- Set-PnPSearchSettings -SearchBoxInNavBar Hidden -Scope Site
Note: The above command must run under the Site Collection, which helps to affect the Site Collection and its respected subsites.
After executing the command in the Powershell, it will display a confirmation dialog box.
Once we have chosen “Yes” in the dialog box, the remove command will be executed.
Check the below screenshot. Microsoft365 search is removed from the top bar on the site.
Enable Microsoft365 Search Bar in SharePoint Online site
Run the below command to enable the Microsoft365 search bar in the current site, which can only enable the changes in the current site.
- Set-PnPSearchSettings -SearchBoxInNavBar ModernOnly -Scope Web
Run the below command to enable Microsoft365 search bar in the Site Collection and its respected subsites.
- Set-PnPSearchSettings -SearchBoxInNavBar ModernOnly -Scope Site
Note
The above command must run under the Site Collection, which helps to enable the Site Collection and its respected subsites.
Check the above screenshot, Microsoft365 search is enabled in the top bar in the SharePoint Online site.
Please refer to this
page to learn more about "Set-PnpSearchSetttings".