0

I am trying to update the SharePoint 2013 on premise portal navigation urls though below powershell. The script is getting executed successfully without any error. But when I am cross checking the site by going to navigation section in site settings.aspx page, no update is there.

Please help me to getting this sorted out.Thanks in advance!

Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue

$SPWeb = Get-SPWeb "https://demosite.com/sites/apps/stiftelsen"

$FindString="abc"

$linkUrl = $linkUrl.ToLower();

$SPWeb.Navigation.QuickLaunch | ForEach-Object {


if($linkUrl.IndexOf($FindString) -gt -1){

    $linkUrl = $_.Url

    Write-Host "Updating $linkUrl with new URL"

    if($_.Title -eq "Application and handling process"){

        $_.Url = $_.Url.Replace($_.Url,"https://google.com")

        $_.Update()

    }

}

}

$SPWeb.Dispose()
0

You could refer to this article to update the link url: http://www.sharepointdiary.com/2013/01/find-and-replace-old-link-urls-in-quick.html

Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue

#Set Old & New URLs
$OldURL = "http://moss2007.crescent.com"
$NewURL = "http://sharepoint2010.crescent.com"

#Get all sites of the web application
$webs = Get-SPWebApplication "http://sharepoint.crescent.com" | Get-SPSite -Limit All | Get-SPWeb -Limit All

#Iterate through webs
ForEach ($web in $webs)
{
    #Get the Quick Launch Bar Nodes
    $QuickLaunchNodes = $Web.Navigation.QuickLaunch
    #For Top Navigation use: $Web.Navigation.TopNavigationBar . TOp Nav may or May not have child nodes

    #Iterate through each Parent nodes of Quick launch
    Foreach ($parentNode in $QuickLaunchNodes)
    {
        If($parentNode.Url -match $OldURL)  #if you want to match Link text, use: $parentNode.Title
        {
            $parentNode.Url = $parentNode.Url.Replace($OldURL,$NewURL)
            $parentNode.Update()
            Write-Host "$OldURL Updated!"
        }
        #Get the Child Nodes
        $childNodes = $parentNode.Children

        #Iterate through child nodes
        Foreach ($childNode in $childNodes)
        {
            If($childNode.Url -match $OldURL)
            {
                $childNode.Url = $childNode.Url.Replace($OldURL,$NewURL)
                $childNode.Update()
                Write-Host "$OldURL Updated!"
            }
        }
    }
}

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.