SharePoint 2013 – Add and Remove Link Items From Search Navigation Using PowerShell

May 11, 2014

Here’s a quick tip on how to add link items to SharePoint 2013 search navigation and how to remove items from search navigation.

Add Items:

$sites=Get-SPsite http://testsite -Limit all | Get-SPweb
$node1 = new-object  -TypeName "Microsoft.SharePoint.Navigation.SPNavigationNode"  -ArgumentList "Link1", "http://site/sites/Search/Pages/pageA.aspx", $true
$node2 = new-object  -TypeName "Microsoft.SharePoint.Navigation.SPNavigationNode"  -ArgumentList "Link2", "http://site/sites/Search/Pages/PageB.aspx", $true
$node3 = new-object  -TypeName "Microsoft.SharePoint.Navigation.SPNavigationNode"  -ArgumentList "Link3", "http://site/sites/Search/Pages/PageC.aspx", $true
foreach ($web in $sites)

Remove items:

$sites=Get-SPsite http://testsite -Limit all | Get-SPweb
foreach($web in $sites){

$navs = $web.Navigation.SearchNav
   foreach ($nav in $navs)
    $nodeid =$web.Navigation.GetNodeById($nav.Id)
    write-host "add id $($nodeid.Id) to array"  
   foreach ($node in $navItems)
    write-host "delete id $($node.Id)"    
Add comment
facebook linkedin twitter email

Leave a Reply

Your email address will not be published.

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>



  1. cogmiosMarch 14, 2015 ב 0:45

    shouldnt it be $idItems+=$nodeid >> $navitems+=$nodeid ?

    1. BobCApril 29, 2015 ב 15:52

      @cogmios is right, there is a type-o in the delete script.

      Change this line $idItems+=$nodeid

      to $navitems+=$nodeid