I know this question has been asked and answered numerous times already, but I am still running into a problem. I used Backup-SPSite and Restore-SPSite to migrate a site from one SP 2010 farm to another. The site contains a managed metadata column, and the managed metadata DB from the source server was backed up and restored on the target.

Now when I edit the metadata of one of the items that contains the managed metadata column, the terms are all red. If I click in the managed metadata field and then click back out again, the items all turn black. The trouble is, I don't want to have to do this for every item, and I also don't want the Modified Date to change for every item.

I did find this script, which is supposed to solve exactly this problem: http://mymemorysucks.wordpress.com/2011/01/07/invalid-terms-in-managed-metadata-field/

Despite the fact that several people report this script working for them in the comments, when I run it I get an exception on the call to $item.Update(). The exception states:

Exception calling "Update" with "1" argument(s): "The URL 'Lists/XXX/YYY.doc" is invalid. It may refer to a nonexistent file or folder, or refer to a valid file or folder that is not in the current Web.

The file is definitely there, and the account running the script does have permissions to edit it. Also, all documents are checked in, and check-out is NOT required to edit a document. What could be causing the issue?

1 Answer 1


I solved it myself. I was able to use the script mentioned in the original post, but needed to modify it slightly. That script was setting the new value of the managed metadata field to $existingTerms[0].GetPath(). I needed to modify that value to remove everything before the last semi-colon ";" character.

In other words, replace:



$eistingTerms[0].GetPath().Substring($existingTerms[0].GetPath().LastIndexOf(";") + 1)

After doing that, the call to $item.Update() worked and my items were all successfully updated.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.