1

I made a backup restore of some site collcetions from production to dev environment. Then I noticed that sometimes when I clicked on the global navigation items on my dev, they were pointing to production.

It looks like the develoeprs of this used absolute urls in the global navigation instead of relative.

I want a script that iterates over all global navigation items, and change that. In that way, I can do the backup restore again and everything should work.

ANy idea how to iterate over all global navigation items in powershell?

3

Try to do something like this:

$siteCollectionUrl = "http://..."
$rootSiteCollection = Get-SPSite $siteCollectionUrl
if ($rootSiteCollection -ne $null)
{
    $rootWeb = $rootSiteCollection.RootWeb
    $navigationNodes = $rootWeb.Navigation.TopNavigationBar // or $rootWeb.Navigation.QuickLaunch
    if ($navigationNodes -ne $null)
    {
        foreach($navNode in $navigationNodes)
        {
            $navNode.Url = //here change your absolute url to your relative url
            $navNode.Update()
        }
    }
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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