Update all quick launch links via PowerShell

As part of the process of upgrading SharePoint or perhaps simply moving web applications to a different URL, sometimes it is necessary to update multiple quick launch links that point to an old URL so they now resolve to a new URL.

These could be links to the ‘old’ SharePoint URL that have been manually created or links to an external system that has had a URL change. Either way, the script below will scan through the entire site and update any links that contain either of the ‘from’ URLs.

NB: SharePoint does a great job of updating ‘internal’ links but this does not stop users creating fully qualified links that contain an old URL nor can SharePoint automatically update links to external URLs

Add-PSSnapin Microsoft.SharePoint.PowerShell –erroraction SilentlyContinue

## urls to search for
$fromURL = "
$fromURL2 = "http://from.another.url"

## the url to be used as a replacement
$toURL = "http://bc01"

foreach ($web in (Get-SPWebApplication $toURL | Get-SPSite -Limit All | Get-SPWeb -Limit All))
    ## scan the web quick launch urls
    Write-Host "Scanning " $web.Url

    $nodes = $web.Navigation.QuickLaunch
    foreach ($node in $nodes)
        $nodeUrl = $node.Url
        if ($nodeUrl.ToString().ToLower().Contains($fromURL) -or $nodeUrl.ToString().ToLower().Contains($fromURL2))
            Write-Host "     found link to: " -foreground gray -nonewline; Write-Host $nodeUrl -nonewline
            ## update the link
            $nodeUrl = $nodeUrl.ToString().ToLower().Replace($fromUrl,$toURL).Replace($fromUrl2,$toURL)
            $node.Url = $nodeUrl
            Write-Host " – done." -foreground green


I hope this helps