I have used this powershell script to update all navigation items in a site collection to use only relative URLs instead of absolute ones.
{
Write-Host -ForegroundColor Green "Processing web" $currentWeb.Url
$currentWeb.AllowUnsafeUpdates = 1
UpdateNavigation($currentWeb)
$currentWeb.Update()
$currentWeb.AllowUnsafeUpdates = 0
foreach($sub
in $currentWeb.Webs)
{
ProcessWeb($sub)
}
}
function
UpdateNavigation($web)
{
$topNavigationNodes =
$web.Navigation.TopNavigationBar
UpdateNavNodes($topNavigationNodes);
$quickLaunchNodes =
$web.Navigation.QuickLaunch
UpdateNavNodes($quickLaunchNodes);
}
function UpdateNavNodes($navNodesCollection)
{
if
($navNodesCollection -ne $null)
{
foreach($navNode
in $navNodesCollection)
{
$navNode.Url =
$navNode.Url.Replace('http://<My Root Site Url>','')
$navNode.Update()
}
}
}
Write-Host -ForegroundColor
red "STARTED"
ProcessWeb(Get-SPWeb
-identity "http://<My Site Collection Url>")
Write-Host -ForegroundColor red "FINISHED"
No comments:
Post a Comment