Add Site to TopNavigationBar in Sharepoint

When Adding a site to the TopNavigationBar, we need to create a New-Object using Navigation.SPNavigationNode. Here’s an example on adding a site to the TopNavigationBar. This is basically the same as when adding the Site to the QuickLaunch.


function Add-SPSiteToTopNav([string]$url,[string]$Site,[string]$SiteURL) {

  [System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint")

  $SPSite = New-Object Microsoft.SharePoint.SPSite($url)
  $OpenWeb = $SpSite.OpenWeb()

  $TopNavBar = $OpenWeb.Navigation.TopNavigationBar

  $Node = New-Object Microsoft.SharePoint.Navigation.SPNavigationNode $Site, $SiteUrl, 1
  $TopNavBar.AddAsLast($Node)

  $SPSite.Dispose()
  $OpenWeb.Dispose()
}

Add-SPSiteToTopNav -url http://wss -Site TheBlog -SiteURL http://wss/TheBlog

sharepoint-16

Rating 3.00 out of 5
[?]

Leave a Reply

Your email address will not be published. Required fields are marked *

*

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=""> <strike> <strong>

Comment Spam Protection by WP-SpamFree