Geeks With Blogs
Points To Share Mostly SharePoint

At times I create so many sites and sub-sites that the Top-Nav cannot handle it. It is better to add the new links to the Quick Launch.

The function below makes it a snap.

Here is how it is used:

The first line inserts a heading "OrgSites" under the "Lists" heading (already there) in the QuickLaunch.

New-SPNode -Web $siteurl -NodeText "OrgSites" -NodeLink "Head" -NodeParent "Lists"

TAnd this line inserts the URL of a site named $web1name and the URL $web1url unter the new "OrgSites" heading

New-SPNode -Web $siteurl -NodeText $web1name -NodeLink $web1url -NodeParent "OrgSites"

Here (FINALLY!!) is the function

# New-SPNode creates an entry in the QuickLaunch navigation
# $Web is the URL of the site
# A node is made of text - $NodeText and link - $NodeLink
# If the link says "Head", then the node is a heading, else it is assumed a URL
# If "Head" then the heading is added immediately under The parent heading ($NodeParent)
# No checking for a URL being a URL
# Nodes are always added last
# Nodes are added under $NodeParent

function New-SPNode {
string]$NodeText, #"Head" if Heading
Start-SPAssignment -Global
= Get-SPWeb -Identity $Web
= $SPWeb.Navigation.QuickLaunch # QuickLaunch
= $QL | where {$_.Title -eq $NodeParent}
# Check if heading
($NodeLink -eq "Head")
$NewHead = New-Object Microsoft.SharePoint.Navigation.SPNavigationNode($NodeText, "")      $QL.Add($NewHead, $PrevHead) | Out-Null



$NewNode = New-Object Microsoft.SharePoint.Navigation.SPNavigationNode($NodeText, $NodeLink)

      Write-Host "New-SPNode: " $Web " " $NodeText " " $NodeParent -ForegroundColor Blue -Backgroundcolor magenta
$PrevHead.Children.AddAsLast($NewNode) | Out-Null
Stop-SPAssignment -Global


That's All Folks!!
Posted on Sunday, May 19, 2013 12:44 PM SharePoint , PowerShell , QuickLaunch | Back to top

Comments on this post: SharePoint QuicLaunch Maker with PowerShell

No comments posted yet.
Your comment:
 (will show your gravatar)

Copyright © PointsToShare | Powered by: