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

2 thoughts on “Add Site to QuickLaunch in Sharepoint

  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

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