Trying to remove "Pending deletion" items cause a lot of (yellow) warnings

Jan 28, 2013 at 3:14 PM

Greetings,

I currently have around 347 items stored in the "deleted items" view, in the administration pane. When using the below PowerShell script, which in turn uses SMLets commands, nothing happens:

import-module smlets
$class = Get-SCSMClass | where{$_.name -match “system.configitem”}
$deletedobjects = Get-SCSMObject -class $class | where{$_.objectstatus -match “Pending”}
$deletedobjects | set-scsmobject -property objectstatus -value deleted

$DeletedObjects however never gets filled. There are a lot of yellow warnings on the screen about a "DisplayName" already being present. After that, nothing.

I'm also unsure if the command  triggers the grooming part of SCSM, which is also explained on:

  • http://blogs.technet.com/b/servicemanager/archive/2009/09/18/data-retention-policies-aka-grooming-in-the-servicemanager-database.aspx  

Anyone got any idea?

Feb 4, 2013 at 9:34 PM
Edited Feb 4, 2013 at 9:36 PM
I'm not sure about the set-scsmobject cmdlet you are using, however when we want to remove an object for immediate purging, we use remove-scsmobject.

As far as being able to populate your $deletedobjects variable, I looked at the object status of one of our objects in the deleted items folder, and it has an objectstatus of "Pending Delete", so your script looks correct.

Also, you are pulling every config item in the system.configitem class before filtering. It would be better (and faster) if you add a filter before passing the result to the where-object cmdlet. This would look like this:

Get-SCSMObject -class $class -filter "objectstatus -match Pending"

Can you try to select just one of your pending delete objects and see if you still see those warnings? You might try something like " $deletedobject = get-scsmobject -class $class -filter "displayname -eq enterobjectdisplayname" "