I'm attempting to run a basic PowerShell script to fix a lot of broken "Send To" destination links that resulted from a site migration from one farm to another.
I wanted to proof-of-concept this on just one document first. As it turns out, there seems to be no way to fix existing links in the collection -- you have to do an SPCopyDestinations.Add() to add the new, correct link into the collection and then SPCopyDestinations.Remove() the existing, broken link.
However, I cannot seem to get the SPCopyDestinationCollection of the item to persist the newly added values to the database.
Here is the PowerShell I ran to try to add a new SPCopyDestination to an item's collection:
PS C:\users\ryan\desktop> $web = get-spweb http://dev.demo.com/sites/sendtoscript
PS C:\users\ryan\desktop> $list = $web.Lists["Original Documents"]
PS C:\users\ryan\desktop> $list.Items[0].CopyDestinations.Add("http://dev.demo.com/sites/sendtoscript/originaldocuments/folder1/doc1.docx", [Microsoft.SharePoint.SPCopyDestinationType]::Update, "")
Url : http://dev.demo.com/sites/sendtoscript/originaldocuments/folder1/doc1.docx
LeafName : doc1.docx
FolderUrl : http://dev.demo.com/sites/sendtoscript/originaldocuments/folder1
Type : Update
ModifiedBy : 1
CreatedBy : 1
Id : 4517a08f-1cc2-4f77-b123-7e7c44373824
Comment :
Collection : {4517a08f-1cc2-4f77-b123-7e7c44373824}
PS C:\users\ryan\desktop> $list.Items[0].Update()
However, upon inspecting the SPCopyDestinationCollection of the item after this, there is nothing there:
PS C:\users\u582290\desktop> $list.Items[0].CopyDestinations
PS C:\users\u582290\desktop>
Any ideas?