Undeclare a Single Record in a List

Following on this forum post, and this blog post, I wanted to be able to undeclare a specific record.  In my case, I wanted to undeclare a record by “ID”, but you could really do this by any (unique enough) attribute of a record.

The code I used to do this was essentially as follows.

[sourcecode lang=”Powershell”]
$SPAssignment = Start-SPAssignment
$sitename = "https://YourSiteGoesHere"
$listname = "YourListNameGoesHere"

$web = Get-SPWeb $sitename -AssignmentCollection $spAssignment
$list = $web.lists[$listname].items

foreach ($item in $list)
{
$IsRecord = [Microsoft.Office.RecordsManagement.RecordsRepository.Records]::IsRecord($Item)
if ($IsRecord -eq $true){
if ($item.id -eq 21412)
{
Write-Host "Undeclared $($item.Title)"
[Microsoft.Office.RecordsManagement.RecordsRepository.Records]::UndeclareItemAsRecord($Item)
}
}
}
Stop-SPAssignment $SPAssignment

[/sourcecode]

The above code goes through all the records in the list, and finds the one that matches the ID I was interested in.  It then undeclares it as a record, and I was then able to make the necessary change.

To customize this to your needs, you’d need to change the highlighted values for the sitename URL, the list name (within the site), and the value of the item’s ID.