This time I will give you a sample script that will enumerate all of your subwebs and remove a node from the current navigation.
A very useful script if you have a large and complec site structure and when you want to change the global or current navigation.
In my example, I am enumerating all subwebs of my sitecollection, and in the current navigation of every subweb, I remove the ‘Ste Pages’ link that you get from enabling publishing. If you want to remove a different link, find the ID of that link and replace or add a $currentnode… to the script.
Since my users have no use for the ‘site pages’ link, I’ll simply remove it from navigation.
# get a sitecollection object(SPSite) $SPSite = Get-SPSite -Identity “http://farm.company.local/sitecollection“ # loop through all the subwebs(SPWebs) in the site collection foreach ($SPWeb in $SPSite.AllWebs) { # Get a navigation node object and delete it $currentnode = $SPWeb.Navigation.GetNodeByID(2001) $currentnode.Delete() # Make it stick... $SPWeb.Update() Write-Host “Removing the Node: ” $currentNode.URL }
A comlex way of finding out a nodes ID, is to do as follows:
$SPWeb = Get-SPWeb "http://farm.company.local/sitecollection/Web"
(Check in site settings/Navigation what the url for the node is, for example:)
$currentnode = $web.Navigation.GetNodeByUrl ("site/Web/SharedDocuments/Forms/AllItems.aspx") $currentnode.ID
That will probably give you the ID 2002 for ‘Shared Documents’
Thats it!