Home > Sharepoint > Add Site to QuickLaunch in Sharepoint

Add Site to QuickLaunch in Sharepoint

When Adding a site to the QuickLaunch, we need to create a New-Object using Navigation.SPNavigationNode. Here’s an example on adding a site to the QuickLaunch.


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

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

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

  $QuickLaunch = $OpenWeb.Navigation.QuickLaunch
  $Node = New-Object Microsoft.SharePoint.Navigation.SPNavigationNode $Site, $SiteURL, 1
  $QuickLaunch.AddAsLast($node)

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

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

sharepoint-15

Rating 3.00 out of 5
[?]
Categories: Sharepoint Tags:
  1. Dishaniti
    October 23rd, 2009 at 14:48 | #1

    Hello

    I tried your code with main site, it works great. But When I tried with my sites (http://domain/personal) it gives error after openweb command, error message is “Invalid Url”

    I want to add 1 link in quicklaunch for all the uses my site.

    Let me know what wrong I am doing?

    Disha

  1. No trackbacks yet.

Spam Protection by WP-SpamFree