Category Archives: Upgrade

Updating SharePoint Absolute URLs With Relative URLs Using Windows PowerShell

One of many common concerns during SharePoint upgrades are hard-coded or broken links.

When you create a list or a document library in SharePoint, you will notice that by default, the list or the document library link has been added to the Quick Launch on the left hand side of your site, Unless Quick Launch has been disabled. That kind of link upgrades with no issues since it is a relative link that SharePoint knows about and knows how to call and reference. However, when users, such as site owners, manipulate the Quick Launch navigation and add additional links, they manually type in the address and description, so that it is easier for their end users to access the link content, that link is what gets broken after an upgrade.

So the question of updating broken link is often a common one. Below we address this common concern to a certain extent. Obviously, hard coded links can be anywhere, on the links web part, inside of documents, on the top link bar, and on the native site Quick Launch.

Below is a script and a video that updates Quick Launch absolute links to relative URLs.

Note: You will have to upate the first four lines of the script your site scope, the quick launch heading, the absolute url you want to change, and the relative url you want to change to.

$site = “http://sharepoint2010/sites/SPQuester
$QuickLaunchHeading = “Libraries”
$absoluteUrl = “http://sharepoint2003/sites/SPQuester/Shared Documents”
$relativeUrl = “./Shared Documents” 
foreach ($web in (Get-SPSite  $site | Get-SPWeb -Limit All))
    $node = $web.Navigation.QuickLaunch | where { $_.Title -eq $QuickLaunchHeading }    foreach($childNode in $node.Children | where { $_.URL -eq ($absoluteUrl) })
        Write-host “Updating” $childNode.Title “on the following site” $web.Url
        $childNode.URL = $relativeUrl
Write-host “Completed Successfully”

Video Length: 2:55