Update Hyperlink Field in SharePoint with PowerShell

I want to change the URL in list item from https://Texas.com to https://ta.com using Powershell script

1) copy & paste (change the URLs and Listnames and field) the below script and name it with extension .ps1 (ex: ItemURLChange.ps1)


#Add-PSSnapin Microsoft.SharePoint.PowerShell

$siteUrl = "http://sharepoint/SiteCollection/SiteName"
$webName = “SiteName”
$listName = "Name of your list"
$spSite = new-object Microsoft.SharePoint.SPSite($siteurl)
$spWeb = $spSite.OpenWeb($webName)
$spList = $spWeb.Lists[$listName]

foreach($Item in $spList.Items )
{
$ofldurl= new-object Microsoft.SharePoint.SPFieldUrlValue($Item["URL"])

$ofldurl.URL = $ofldurl.URL.Replace("Texas", "ta")
$ofldurl.Description = $ofldurl.Description.Replace("Texas", "ta")

$item["URL"] = $ofldurl
$item.update()
}

$spWeb.Dispose()

2) Open the Powershell command and run using the below command

PS C:\temp> ./ItemURLChange


http://www.sharepointed.com/2011/09/09/update-hyperlink-field-in-sharepoint-with-powershell/

Comments

Popular posts from this blog

SharePoint 2016 and 2019 Ports

Unlock the SharePoint site using Powershell command

PsConfig step by step /Configuration Wizard. “Upgrade Available” vs “Upgrade required”