Closing this message and/or accessing our website tells us you are happy to receive all cookies on the ClearPeople website.
However, if you would like to, you can change your cookies settings at any time.
SharePoint 2007: How to clear the automatically generated Quick Launch titles and links using PowerShell

Today I had a requirement to remove all the headings and links from the quick launch of SharePoint sites (webs) as they were being created by a PowerShell deployment script.

SharePoint sites

I knew it was possible as I did something similar on a project with SharePoint 2007. So you would have thought that it would have been a relatively simple task, however I didn’t have access to this previous script and couldn’t quite remember how I achieved it.

In the end I did a little research and found some example PowerShell scripts which were about working with the quick launch. One post from Get-SPScripts did what I was after but was part of a much larger script. In the end this is what I ended up with:

function Clear-QuickLaunch($url){

$SPWeb = Get-SPWeb $url

$QuickLaunch = $SPWeb.Navigation.QuickLaunch

$Nodes = @()

$QuickLaunch | ForEach-Object {

$Nodes = $Nodes + $_.Id

}

$Nodes | ForEach-Object {

$Node = $SPWeb.Navigation.GetNodeById($_)

$Node.Delete()

}

}

Clear-QuickLaunch “http://sharepoint/”

SharePoint Management Shell

I got off to a rather slow start as I had forgot to set the $Nodes variable to an empty array and PowerShell kept throwing this error.

This was because $Nodes = $Nodes + $_.Id was performing a sum calculation rather than building up an array of all the objects. All was resolved once I remembered to include $Nodes = @() before using the $Nodes variable as an array.

SharePoint sites

Author bio

Comments


comments powered by Disqus

Related Articles

Sign up to our Newsletter ClearThought

Get inspired and learn something new by subscribing to our FREE bi-monthly newsletter. It’s full of ClearPeople's thought leadership whitepapers, blogs, events, and much more.
We promise to not use your email for spam.