You may get some errors while running this script but you will find that its worked too :)
URL FIX
$hubUrl = "NEW_NAME_OF_WEBAPP"
$find = "OLD_NAME_OF_WEBAPP"
"Installing..."
Add-PSSnapIn Microsoft.SharePoint.PowerShell
if ([Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint") -eq $null) { throw "Unable to load Microsoft.SharePoint.dll!"; }
"Upgrade visual web to v4..."
$site = Get-SPSite $huburl
$site.VisualUpgradeWebs()
$site.Dispose()
$hubUrl = $hubUrl.TrimEnd('/');
$web = Get-SPWeb $hubUrl
function UpdateNodeCollection
{
param([Microsoft.SharePoint.Navigation.SPNavigationNodeCollection]$nodes)
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)
$node.Url = $nodeUrl
$node.Update()
Write-Host " – done." -foreground green
}
UpdateNodeCollection $node.Children
}
}
function UpdateQuickLaunch
{
param([string]$fromURL, [string]$toURL)
foreach ($qlweb in (Get-SPSite $toURL | Get-SPWeb -Limit All))
{
## scan the web quick launch urls
Write-Host "Scanning " $qlweb.Url
$nodes = $qlweb.Navigation.QuickLaunch
UpdateNodeCollection $nodes
$nodes = $qlweb.Navigation.TopNavigationBar
UpdateNodeCollection $nodes
$qlweb.Dispose()
}
}
"Fixing Navigation"
$replace = $hubUrl + "/"
UpdateQuickLaunch $find $replace
"Installation Complete!"