I am able to bypass the lock and update the managed meta data field only if I run the file containing the following code twice.
Any idea how I can modify this to achieve the goal with only one time execution of the code?
try
{
[Microsoft.Office.RecordsManagement.RecordsRepository.Records]::UndeclareItemAsRecord($item);
Write-Host "Undeclaring document named " + $item.Title
$MMSField.SetFieldValue($item,$spTerm);
$item.Update()
}
catch
{
Write-Host "Could not undeclare record. ERROR: " + $_.Exception.Message
}
faye fouladi