3

Is there an elegant recommended way or tool that allows updating URL's inside documents in SharePoint 2013 after a migration?

1

I assume you are looking for the tool / script to update links (URLs) referred in the wiki pages after migration. If you are looking for a tool to migrate across SharePoint and replace the URLs inside the pages (web parts), then you can take a look at Vyapin’s XPlica for SharePoint.

If you are looking for a tool / script to update the URLs in the web pages alone after migration, then I will give you the below PowerShell script that will help you to replace the old links with the new links with respect to target location.

Param([parameter(Mandatory=$true)][alias("Url")]$SPWebUrl, [parameter(Mandatory=$true)][alias("ListName")]$SPListName, [parameter(Mandatory=$true)][alias("Search")]$SearchString, [parameter(Mandatory=$true)][alias("Replace")]$ReplaceString)

Add SharePoint PowerShell SnapIn if not already added

if((Get-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue) -eq $null)
{
Add-PSSnapin Microsoft.SharePoint.PowerShell
}

Get SharePoint website object

$SPWeb = Get-SPWeb $SPWebUrl

Get SharePoint list object

$SPList = $SPWeb.Lists[$SPListName]

Iterate through each item in the Wiki Library

foreach($SPListItem in $SPList.Items)
{

Check if $SPListItem contains $SearchString

if($SPListItem["ows_WikiField"] -and  $SPListItem["ows_WikiField"].contains($SearchString))
{

Check out page

$SPListItem.File.CheckOut();

Replace $Search_String with $Replace_String and update item

$SPListItem["ows_WikiField"] = $SPListItem["ows_WikiField"].replace($SearchString, $ReplaceString);
$SPListItem.Update();

Check in page

$SPListItem.File.CheckIn("Checked in by system");
Write-Host "Completed"
}
}

Note: Run the PowerShell as Administrator on the target SharePoint server and execute the above script using Windows PowerShell.

1
  • not only in Wiki pages. I am really looking for a script that updates URL's inside .doc and .docx files. Nov 28 '17 at 11:23

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.