SCSM – Deleting Individual Items

System Center

When using System Center Service Manager (SCSM) you can sometimes end up with Incidents, Change Management items or Service Requests that need to be deleted individually. You an carry this out by using a combination of SMLets and PowerShell.

INSTRUCTIONS

The first thing you will need to do is to download and install SMLets on your Service Manager server. Once this is complete you should then go ahead and start up an elevated PowerShell ISE window.



Depending on what item you want to delete, copy and paste the below code into your script panel within the PowerShell ISE window:

# Import SMLets
import-module smlets

# State the required class
$class = get-scsmclass | where{$_.name -eq “system.workitem.changerequest”}

# Use below to edit/remove all items within the above stated class (the array)
# $CRsList = get-scsmobject -class $class

# Use below to edit/remove statuses of all items like (below exam is to edit all items with *submit* status) (the array)
$CRsList = get-scsmobject -class $class | where{$_.ID -like “CR#####”}

# Remove all items stated within the $CRsList Array
Foreach ($CR in $CRsList) {Remove-SCSMObject $CR -Confirm:$false -Force}

# Change all statuses within the array – you will be prompted for a new status
# $CRsList | set-scsmobject –property status

The above code as is will delete a stated Change Request item. Remember to change the #’s for the item number you wish to delete.

If you want to delete other items such as an Incident or Service Request, you should amend these values in the code:

  • system.workitem.changerequest
  • $CRsList
  • CR#####
Feedback

If you have any questions or feedback on this post, please feel free to leave us a message below in the comments section.



Leave us a message...