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
[?]
