Velin Georgiev Blog

Use PowerShell to configure SharePoint search result page tabs

Have you ever wondered how you can modify the SharePoint search results page tabs or so-called Search Navigation web part programmatically?

Well there is a way although it does not seem obvious. I tried to search google for that and it did not gave me what I wanted so perhaps I was not using the right phase. I used SharePoint search results page "tabs" as phase, but this is actually called Search Navigation. Having that in mind we can find the answer in the PnP Navigation cmdlets. Here is the code snippet that can change the tabs programmatically using SharePoint PnP PowerShell cmdlets.

$relativeUrl = "/sites/search-site"


# get all the search navigation tabs and remove them
Get-PnPNavigationNode -Location SearchNav | foreach { Remove-PnPNavigationNode -Identity $_.Id -Force }

# add new search navigation tabs
Add-PnPNavigationNode -Location SearchNav -Title "My Custom Results" -Url "$relativeUrl/Pages/my-results.aspx"
Add-PnPNavigationNode -Location SearchNav -Title "My People" -Url "$relativeUrl/Pages/my-people-results.aspx"

PnP provides three functions to deal with navigation Add-* , Get-* and Remove-*, but this is enough to manage the search navigation programmatically.

Change the search result page tabs from the user interface

To do that from the UI, we have to be site collection administrators and navigate to the site settings and then under the Search section you can find the Search Settings URLs. Once we open the page we will see the section where we can modify the tabs.


This is another useful piece towards automation and escape from the UI interactions. I use it for fully automated provisioning of new SharePoint search sites since we have to deploy search site per language.