When you deploy Service Manager into an environment, there will be times when you will need to test and make sure all is working before you deliver the end product to the appropriate person or business. By doing that you might end up with lots of test Work Items (Incidents, Service Requests, Activities, Problems, Change Requests) that you can’t delete from the Console directly. To overcome this, you can use PowerShell or Service Manager Shell to delete the Work Items directly from the Database.
Bear in mind that once deleted, you can’t retrieve them anymore, so make sure you really want them deleted and that you are deleting the right one.
Table of Contents
Getting started
If you choose to use PowerShell, We’ll start by finding your Service Manager install directory, where is has its PowerShell module saved as you might need to import it. The default location is ‘C:\Program Files\Microsoft System Center\Service Manager\Powershell\System.Center.Service.Manager.psd1’. If you choose to use Service Manager Shell, you can just start it from the Start Menu as Administrator.
If using PowerShell, You can import the SMlets, You don’t need this if using Service Manager Shell. Always Open PowerShell as Administrator to give your the right permissions to carry on these tasks.
Import-Module 'C:\Program Files\Microsoft System Center\Service Manager\Powershell\System.Center.Service.Manager.psd1' -force
# Define which activity type in $ActivityID variable (Manual=MA, Review=RA...) then add the * after the ID in the prompt. EG: RA*
Import-Module SMLet
$ActivityID = Read-Host "Set Your Activity Type"
Get-SCSMClassInstance -Class (Get-SCSMClass -Name System.WorkItem.Activity) | Where-Object {$_.ID -ilike "$ActivityID"} | Remove-SCSMClassInstanc