Recently someone expressed his issue of unable to remove the columns "Barcode", "Barcode Value" and "Exempt from Policy" from the list even after the policy is removed. These columns can be simply removed from the view by going into the view settings and checking these columns. However the requester expressed his concerns as why these columns where still there and why there were not removed when there the policy was removed. Hence to solve this I created the following script. It takes the site URL and list name as input values.

There was no option to delete these columns through the UI.
When initially I tried removing them from script, I got this: Exception calling "Delete" with "0" argument(s): "Operation is not valid due to the current state of the object."

function GetHelp() {
 $HelpText = @"
 This script will remove the columns "Barcode", "Barcode Value" and "Exempt from Policy" from a list. These columns are added when Barcodes are enabled using IRM
 policy. Even after the policy is withdrwan these columns stay in the list of columns under view settings.
function RahulDeleteBarcodeIRMPolicyColumns() {
  write-host "This script will remove barcode related columns from your list. Before executing this tool make sure that you have removed the policy otherwise it
 will take you to some other issues"
        write-host "Please enter your site url"
         $siteURL = read-host
         write-host "Please enter your List Name"
         $listName = read-host
         $site = New-Object Microsoft.SharePoint.SPSite($siteURL)
         $Web = $site.OpenWeb()
         $web.AllowUnsafeUpdates = $true
         $listSource = $web.Lists[$listName]
         $columnNames = @("Barcode", "Barcode Value", "Exempt from Policy")
         for ($i = 0; $i -lt $columnNames.Length; $i++)
            $fieldtoBedeleted = $listSource.Fields[$columnNames[$i]]
            $fieldtoBedeleted.AllowDeletion = $true
            $fieldtoBedeleted.Sealed = $false
         $web.AllowUnsafeUpdates = $false
         write-host "The columns are deleted successfully"
if($help) { GetHelp; Continue }
 else { RahulDeleteBarcodeIRMPolicyColumns }

I modified my script and now it is working fine. This has been tested in both Sharepoint 2007 and Sharepoint 2010. If you are executing this make sure you have removed the policy otherwise you will face some other issues

I hope this will help you out.

Rahul Rashu