Thursday, 21 April 2011

Managing Quick Launch (Current) navigation for SharePoint Publishing sites using PowerShell

A few weeks back I published an article on using PowerShell to manage the Quick Launch (otherwise known as “Current”) navigation on SharePoint Foundation sites – or sites in SharePoint Server 2010 where the “SharePoint Server Publishing Infrastructure” site collection feature is not activated.

In this article I will go through a similar scenario of managing headings and links in Quick Launch navigation, but this time where you are using SharePoint Server with the Publishing Infrastructure feature enabled on the site collection. There is also an extra scenario to mention here as well, where the sites within the site collection are actual publishing sites – i.e., sites with the “SharePoint Server Publishing” site feature activated.

First, to clarify, the “SharePoint Server Publishing Infrastructure” feature can be activated on the site collection from the Site collection features option in the Site Settings administration page on the root site of the site collection:


I’m not going to go into the exact specifics of what this feature does, but from a navigation point of view, it provides extra options for inheriting links from parent sites, automatic sorting, and additional options for headings and links, including setting a separate title and description, opening in a new window, and applying audience filtering.

Because of these additional options, the code for managing headings and links in PowerShell is also different. First, we need to get the Web, PublishingWeb and QuickLaunch objects and assign them to variables. For this example, I am modifying the root site of a site collection created at http://portal/sites/nav:

$web = Get-SPWeb http://portal/sites/nav
$pubWeb = [Microsoft.SharePoint.Publishing.PublishingWeb]::GetPublishingWeb($web)
$qlNav = $pubWeb.Navigation.CurrentNavigationNodes

If you would like to see a list of headings already created on the site with their node ID’s, type the following:

$qlNav | select Title, ID


To make changes to a heading, we need to assign it to a variable first. There are methods to do this with the ID and link URL, but I prefer to use the heading Title as it’s more user friendly and will be the same across each site. For example, type this command to get the Libraries heading:

$qlHeading = $qlNav | where { $_.Title -eq "Libraries" }

If there is more than one heading with the same name, you will need to type the following command to select the correct one. Changing the number in the square brackets will be how you do this, with 0 being the first heading, 1 the second heading, 2 the third heading, etc.

$qlHeading = ($qlNav | where { $_.Title -eq "Libraries" })[0]

If you are looking to move the heading order, then you need to get the heading you wish to move, the heading that you wish it to appear under, and then apply the Move method. For example, to move the Lists heading to appear underneath the Discussions heading, type the following:

$qlHeading = $qlNav | where { $_.Title -eq "Lists" }
$qlNewPreviousSibling = $qlNav | where { $_.Title -eq "Discussions" }
$qlHeading.Move($qlNav, $qlNewPreviousSibling)


So far, this script has been almost the same as the script for managing Quick Launch navigation in SharePoint Foundation sites – however, here is where it is all about to change. Before I start creating new navigation items, I will assign the CreateSPNavigationNode method to a variable to make it easier to invoke later on in the script:

$CreateSPNavigationNode = [Microsoft.SharePoint.Publishing.Navigation.SPNavigationSiteMapNode]::CreateSPNavigationNode

To create a new heading or link, you have to specify the following information:

  • Display Name – Will appear in the Quick Launch as the name of the item
  • URL – Hyperlink address for the item. You can set this with double-quotes if you do not want to set a URL for the item
  • Node Type – This will specify the type of node available in SharePoint 2010 – e.g., Heading for a navigation heading and AuthoredLinkPlain for a generic link. You can get a full list of available node types from this article:
  • SPNavigationNodeCollection to add the new node into

For example, the following lines of script will add a new heading called “External Links” under the existing “Libraries” heading:

$qlNewPreviousSibling = $qlNav | where { $_.Title -eq "Libraries" }
$headingNode = $CreateSPNavigationNode.Invoke("External Links", "", [Microsoft.SharePoint.Publishing.NodeTypes]::Heading, $qlNav)
$headingNode.Move($qlNav, $qlNewPreviousSibling)


To add links to a heading, we use the same CreateSPNavigationNode method as before, with the same properties. First, we get the heading that the links will appear under and then add them to the heading as children. In the example below I add one internal and two external links to our new External Links heading:

$qlHeading = ($qlNav | where { $_.Title -eq "External Links" }).Children
$linkNode = $CreateSPNavigationNode.Invoke("Get-SPScripts", "", [Microsoft.SharePoint.Publishing.NodeTypes]::AuthoredLinkPlain, $qlHeading)
$linkNode = $CreateSPNavigationNode.Invoke("Links", "/sites/nav/Lists/Links/AllItems.aspx", [Microsoft.SharePoint.Publishing.NodeTypes]::AuthoredLinkPlain, $qlHeading)
$linkNode = $CreateSPNavigationNode.Invoke("Follow me on Twitter", "", [Microsoft.SharePoint.Publishing.NodeTypes]::AuthoredLinkPlain, $qlHeading)

Because the $linkNode variable is being assigned as each link is created, you can use this opportunity to set additional properties, such as a Description, Target (i.e., Open link in new window), and Audience. Adding the section of script below directly after the “Follow me on Twitter” link has been created will set the options shown in the following screenshot:

$linkNode.Properties["Description"] = "Test description created with PowerShell"
$linkNode.Properties["Target"] = "_blank"
$linkNode.Properties["Audience"] = "All site users"


To view a list of these links after creation, type the following command:

$qlHeading | select Title, ID


Finally, to move the link order, you need to get the link you wish to move, the link that you wish it to appear under, and then apply the Move method. The link can be assigned to a variable by accessing the Children property of the heading. For example, to move the “Follow me on Twitter” link to appear underneath the “Get-SPScripts” link, type the following:

$qlNewPreviousLink = $qlHeading | where { $_.Title -eq "Get-SPScripts" }
$qlLink = $qlHeading | where { $_.Title -eq "Follow me on Twitter" }
$qlLink.Move($qlHeading, $qlNewPreviousLink)


The end result of all this scripting is that we now have a new heading and three links underneath that heading:


Configuring Quick Launch Options

As mentioned at the start of this article, activating the “SharePoint Server Publishing Infrastructure” site collection feature provides extra options for inheriting links from parent sites and automatic link sorting. To configure these in PowerShell, start by getting the Web and PublishingWeb objects and assigning them to variables. To show the inheritance options available, this example calls a sub-site to the root of the http://portal/sites/nav site used earlier:

$web = Get-SPWeb http://portal/sites/nav/subsite
$pubWeb = [Microsoft.SharePoint.Publishing.PublishingWeb]::GetPublishingWeb($web)

The following table shows the options available in the UI followed by the corresponding script to modify them using PowerShell:

image Display the same navigation items as the parent site:

$pubWeb.Navigation.InheritCurrent = $true
$pubWeb.Navigation.ShowSiblings = $false

Display the current site, the navigation items below the current site, and the current site’s siblings:

$pubWeb.Navigation.InheritCurrent = $false
$pubWeb.Navigation.ShowSiblings = $true

Display only the navigation items below the current site (shown left):

$pubWeb.Navigation.InheritCurrent = $false
$pubWeb.Navigation.ShowSiblings = $false

image Show subsites:

$pubWeb.Navigation.CurrentIncludeSubSites = $true


Show pages (publishing sites only):

$pubWeb.Navigation.CurrentIncludePages = $true

image Maximum number of 30 dynamic items to show within this level of navigation:

$pubWeb.Navigation.CurrentDynamicChildLimit = 30

image Sort manually:

$pubWeb.Navigation.OrderingMethod = "Manual"

image Sort automatically:

$pubWeb.Navigation.OrderingMethod = "Automatic"

Sort by Title (shown left):

$pubWeb.Navigation.AutomaticSortingMethod = "Title"

Sort by Created Date:

$pubWeb.Navigation.AutomaticSortingMethod = "CreatedDate"

Sort by Last Modified Date:

$pubWeb.Navigation.AutomaticSortingMethod = "LastModifiedDate"

Sort in ascending order (shown left):

$pubWeb.Navigation.SortAscending = $true

Sort in descending order:

$pubWeb.Navigation.SortAscending = $false

image Sort manually with automatic page sorting (publishing sites only):

$pubWeb.Navigation.OrderingMethod = "ManualWithAutomaticPageSorting”

Once you have chosen the options for the script, add the following lines at the end to apply the changes and dispose of the SPWeb object:



  1. Very nice post!

    I just wanna correct one thing:

    It chould be: $qlLink = $qlHeading.Children | where { $_.Title -eq "Follow me on Twitter" }

    (added Children).


    1. Great Article IoT Projects for Students

      Deep Learning Projects for Final Year

      JavaScript Training in Chennai

      JavaScript Training in Chennai

      The Angular Training covers a wide range of topics including Components, Angular Directives, Angular Services, Pipes, security fundamentals, Routing, and Angular programmability. The new Angular TRaining will lay the foundation you need to specialise in Single Page Application developer. Angular Training

  2. Hi, I have tried lot of times but i have the below problem.
    1. I want to add links under the globalnavigation and as of now globalnavigation does not have any header/links. it is blank.
    2. In that case, I am not able to create the object of $qlHeading, which is required everytime when we create the link. can you help me with that.
    Thanks Labhesh

  3. Hi, I have tried lot of times but i have the below problem.
    1. I want to add links under the globalnavigation and as of now globalnavigation does not have any header/links. it is blank.
    2. In that case, I am not able to create the object of $qlHeading, which is required everytime when we create the link. can you help me with that.
    3. the reason we can't create $qlHeading object because it will be blank/null. and it is giving error.
    Thanks Labhesh

  4. Nice post. Helped me out a lot.
    I have a small problem with setting the "Audience" property though.
    The audience is set to a sharepoint group but the item will not show in the Quick Launch menu.

    If I then go to navigation under site settings and edit the newly created link, I can see that the audience is set correctly.

    After pressing OK the new link will show in the menu.
    Looks like the audience is not updated until you manually go in and press OK on the link.

    Any idea why this is?

  5. Update. Found the answer.
    Since it's a Sharepoint group you need to put four semicolons (;;;;) in front of the group name.

  6. So would this be the script to update all Sorting to Automatic for http://portal? If so it doesn't seem to work for me. I am probably missing something. Please advise me on how to update my script to update all subsites under http://portal to Automatic Sorting.

    My Script:
    Sort automatically:
    $web = Get-SPWeb http://portal
    $pubWeb = [Microsoft.SharePoint.Publishing.PublishingWeb]::GetPublishingWeb($web)
    $qlNav = $pubWeb.Navigation.CurrentNavigationNodes
    $pubWeb.Navigation.OrderingMethod = "Automatic"

  7. Thanks for the post. I used this and reworked it as a quick way to delete a link that got pushed out to all my sites from Central Admin. You can see my post at:

  8. Brilliant! Thanks for sharing!

  9. What if I want a N-Level structure?
    -External Links
    > Links
    >> More Links
    >>> Link01
    >>> Link02
    >> Other Links
    > Follow me
    - Libraries

  10. Hi,

    I am unable to set Audience property for the link created by powershell script above.
    Any suggestions ?


  11. hi i am working on SharePoint 2013, i am facing problem in quick launch in current navigation

    while navigating to site its generating an extra heading(suppose i am clicking any link inside "Investor" , its goes to sub site "investor" and showing addition heading with name "investor" having url welcome page )

    please help

    1. I'm having the same issue in Sharepoint 2010.

      Did you find an answer?


  12. الان مع افضل ما توصل له علم الديكورات الحديث من تصميمات نقدم لكم جماليات ورق جدران ثلاثى الابعاد بطلائاتها الجديدة لمنتجات ورق جدران ثلاثي الابعاد فى الرياض فالان ان كنت بمرحلة الانشاء لمنزلك وترغب فى تصميم افضل الديكورات بمنزلك واختيار افضل دهانات الحوائط او ورق حائط ثلاثي الابعاد و ورق الجدران لغرف النوم وايضا دهانات دكتور بينت فكل انواع الدهانات الحديثة نقدمها لكم عملائنا الكرام .

    نحن نقدم كل جديد فى عالم الديكورات ونوفر لكم ورق جدران للمطبخ وللصالات بافضل استايل وخاص فقط بنا وبجودة عالية جدا ولكل من يبحث عن الرقى والجودة فنحن نقدمها لك باقل الاسعار وبافضل الخامات للارضيات والحوائط وكافة اعمال الديكورات ونقدم لعملائنا التى تم التعامل معهم افضل انواع الديكورات مثل ورق الجدران ثلاثى الابعاد بالرياض وبجدة وبالدمام الذي يجعل منزلك قطعة من لوحة فنية .

  13. I got very excited to see these trendy looks. I think all those who are looking of latest trends will really enjoy reading your post. Please provide more information and photos. I am eagerly waiting for your updated post to get it.

  14. If a top is undoubtedly delivered big event set time it will encounter a 20% re selling expense as well refusal. For something to qualify for returning or transaction, The information need to in actual position applying the providing it arrived in. Ought to came equipment label is split or is passing up however there are a Restocking charge all the way to 20%.

    Such a selection incorporates suitable traditions requirements, Place a burden on, Stock broker besides other camisetas de futbol baratas fines. That Maglie Da Calcio a Poco Prezzo portion is at juegos de futbol the mercy equipement foot of change before you make fees. The local surf forecast in an european fellow associate tell maillot foot 2018 you rather Coach Outlet Online Store than indian, Importance tax during this decide to buy isn't recoverable.

    This skill number consists of topical fashions profession, Fees, Brokerage house likewise costs. All of your deal is manuel neuer trikot rot controlled by change if you do not make payment amount. Maglie Calcio Poco Prezzo The local surf forecast in an european union user state dfb trikot müller government better united kingdom, Signific Maillot De Foot Pas Cher value-added tax from this pick up just isn't recoverable.

  15. It is a time consuming process to locate a legitimate, high-quality designer Michael Kors Handbags On Sale at a decent price. One brand name that is sought after is the Michael Kors Bags On Sale. Anywhere you see high demand you will find people out to make a quick buck.

  16. There are those who want to collect vintage items like Michael Kors Factory Outlet with genuine and high quality leathers from Michael Kors. To be able to grab a quality Michael Kors Bags Outlet item of your choice, make sure to be very careful in selecting what to buy, how to buy and where to buy the Michael Kors Outlet Online.

  17. In my opinion, what you have said will definitely be very interesting for all readers, especially me
    I think this information is really incredibly good, and I'm very happy for all that you've shared this
    Greetings know and good luck always

    Obat Benjolan Di Selangkangan Sering Buang Air Kecil Obat Budug Benjolan Di Payudara Obat Herbal Kaligata Cara Menghilangkan Benjolan Di Vagina Obat Infeksi Lambung Obat Infeksi Jamur Pada Miss V Obat Herbal Usus Buntu Manfaat Susu Kambing Etawa untuk Mencegah Osteoporosis

  18. jika anda sedang membaca buku kesehatan, janganah anda membaca setengah - setengah akan tetapi klik disini agar anda paham mengenai maksud dan solusi kesehatan yang anda cari. Anda pun bisa membikin sendiri ramuan kuat dan tahan lama lelaki yang diracik dari baha tradisional yang terdapat pada pasar disekitar anda.

    Ladyfem merupakan obat herbal mengatasi miom, jika anda ingin mengtehaui tentang penjelasan yang lengkap tentang ladyfem buka halaman blog kami, ataupun klik disini Anda juga bisa beli disini jika dikota anda tidak menemukan produk yang anda cari ataupun download di youtube video tentang cara sehat untuk wanita. baca blog untuk info tentang kesehatan klik disini

  19. it needs to be re-installed, and specialists in dealing with chewing gum or furniture, whether in the jaw, packing, cleaning, storage or installation.ارخص شركة نقل اثاث


  20. مكافحة حشرات بالخبر مكافحة حشرات بالخبر
    مكافحة حشرات بمكة مكافحة حشرات بمكة
    مكافحة حشرات بالمدينة المنورة مكافحة حشرات بالمدينة المنورة
    مكافحة حشرات بالدمام مكافحة حشرات بالدمام

  21. The former, in the synchronous Discount Jordan Shoes Wholesale dataflow Cheap Yeezy Shoes tradition, aligns Ray Ban Prescription Sunglasses with Real Yeezy Shoes the temporal and declarative Jordan Shoes For Sale Cheap nature of music, while the latter allows Coach Outlet Store Online declarative interfacing with external components as needed for full fledged musical applications. The paper is a case study around the development of Air Jordan 1 Sale an interactive Ray Ban Sunglass Hut cellular automaton for composing groove based music. It illustrates the interplay between FRP and RVR MK Outlet as well as programming techniques and

  22. If they came down 15 per cent from top to bottom, they would still be where they were around 2016 when prices were still high, he said. They do correct and stay there for a few years, maybe wages will catch up, but that a big if. Introduction of stricter lending criteria by Coach Outlet Online 80 OFF the banks may dampen Cheap Nike Air Force 1 investor demand and reduce Cheap Air Forces some upwards price pressure, but it is a double edged sword that also hurts first homebuyers, he added..

    Causes Diagnosis of Coach Outlet Clearance Sale ADHDThe name deficit disorder was first introduced in 1980 in the third edition of the Diagnostic MK Outlet Online and Statistical Manual of Mental Disorders, the reference manual for mental illness in the MK Outlet Sale United States. In 1994 the definition was altered to include three different types of groups: the predominantly hyperactive impulsive type; the predominantly inattentive type; and the combined type (in the DSM 5, these are now referred to as causes remain unknown, but ADHD can be diagnosed and effectively treated. Many resources are available to support families in managing ADHD behaviors when they occur.

    Perhaps you sent some mixed signals about needing to be free and also needing human contact though in fact both are true, and they don't contradict. This year begins Jordan Shoe Stores a process of Coach Outlet Purses On Clearance tidying up your boundaries. Start with something simple, like making sure all your doorknobs work; and if a lot of housemates have passed through, change your lock.

  23. This comment has been removed by the author.