Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I've created a few sites using this command,

> New-SPWeb -url "http://server" -Template "STS#0" -Name "test99" -Description "test99" -UseParentTopNav

The sites are appearing in the navigation bar as expected but not in the order I would like them.

With this page _layouts/AreaNavigationSettings.aspx under Navigation Editing and Sorting I can change the order they appear in, but is this possible using PowerShell?

I found this page - managing-quick-launch-current - which appears to do something similar with QuickLaunch. But it doesnt appear to manually set the sort order.

share|improve this question
    
It's certainly possible because it can be done from .NET. Here's a starting point for adding a link (for 2007 but can be adapted). Hopefully the TopNavigationBar property is populated in 2010 (wasn't in 2007) or you may need to populate it yourself. –  Alex Angas Apr 21 '11 at 5:44
    
AFAIK it's only populated for publishing sites. Above is a Team Site. –  Tim Ebenezer May 6 '11 at 10:17
add comment

1 Answer

up vote 3 down vote accepted
+25

The following URL gives an example.

Below is a small adaptation :

$url = "http://localhost:29688"
$topsite = Get-SPSite $url; 
$topweb = $topsite.OpenWeb()
$topnavs = $topweb.Navigation.TopNavigationBar


//this adds removes the first  navigation item in the topNav andadds it as a child itemn of the "Solutions" item
 $node0 = $topnavs[0]
 $node0.Children.Delete($node0.Children[0])}
$node1 = new-object Microsoft.SharePoint.Navigation.SPNavigationNode -argumentlist @("Solutions", "/solutions", $False)
$node1 = $node0.Children.AddAsLast($node1)
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.