Environment: SharePoint Server 2016 On Premise Farm
Issue: Users are getting file not found error when they try to share a document in a document library. The Share URL is similar to below
- This issue is only for some of the documents in the library.
- Multiple site collections having this issue
- Recently we changed the web application site URL
- ULS log with error as "Website with name http://oldhostname.domain.com/SC1 is not existing"
https://newhostname.domain.com/http://oldhostname.domain.com/SC1/_layouts/15/DocIdRedir.aspx?ID=VQ47HSUWTZ35-2043059275-2304
Error message: something when wrong file not found
Troubleshoot:
Fix:
Since the host name was recently renamed, the document properties were still referencing to the old URL, (not sure why). Following PowerShell code is to update affected documents with new host name.
$spSite = Get-SPSite -Identity https://newhostname.domain.com/LIT
$website = $spSite.OpenWeb()
$list = $website.Lists["Documents"]
$items = $list.GetItems()
foreach($item in $items)
{
if($item["_dlc_DocIdUrl"].Contains('oldhostname.domain.com') )
{
$item.File.CheckOut()
$item["_dlc_DocIdUrl"] = $item["_dlc_DocIdUrl"].Replace('http://oldhostname.domain.com','https://newhostname.domain.com')
$item.update()
$item.File.CheckIn("DocIdUrl updated")
write-host $item.Name " updated"
}
}
No comments:
Post a Comment