Mar 24 2019 04:15 PM
Good morning, I am new to PS so would appreciate any help.
We have just migrated our SharePoint WSS 3.0 sites to SPO. We have found that in lists which contain a field with URLs, the url in the field has not updated to the relevant SPO location, it is still referencing WSS location. When users go to the list and click on the link in the Pending field, they are being navigated to an incorrect site.
How can I use PS to update field Pending where it begins with https://sharepoint to https://sharepoint1/sites
Thank you in advance.
Vera Hawkins
Mar 25 2019 07:51 AM
@EddoriaHi Vera,
I'm no expert but the way I would do this is to use the PnP Powershell module.
You can install the module using: Install-Module SharePointPnPPowerShellOnline
Mar 25 2019 09:42 PM - edited Mar 25 2019 09:54 PM
SolutionTry this Pnponline powershell script and it will replace the word in your existing URL field value
Connect-PnPOnline -Url https://contoso.sharepoint.com/sites/test
$items =Get-PnPListItem -List testlist
foreach ($item in $items)
{
if($item.FieldValues["URL"].URL-ne $null)
{
$Oldvalue = $item.FieldValues["URL"].URL
$Newvalue = $Oldvalue -replace "sharepoint","sharepoint1/sites"
Set-PnPListItem -List testlist -Identity $Item.Id -Values @{"URL" = $Newvalue}
}
}
Mar 25 2019 09:42 PM - edited Mar 25 2019 09:54 PM
SolutionTry this Pnponline powershell script and it will replace the word in your existing URL field value
Connect-PnPOnline -Url https://contoso.sharepoint.com/sites/test
$items =Get-PnPListItem -List testlist
foreach ($item in $items)
{
if($item.FieldValues["URL"].URL-ne $null)
{
$Oldvalue = $item.FieldValues["URL"].URL
$Newvalue = $Oldvalue -replace "sharepoint","sharepoint1/sites"
Set-PnPListItem -List testlist -Identity $Item.Id -Values @{"URL" = $Newvalue}
}
}