SCSM - Delete groups of tickets using PowerShell SMLets

 


Our SCSM help desk got flooded with tickets due to a glitch, so I needed a way to mass delete a bunch of tickets. For this I used PowerShell SMLets

There is probably a better way to do this than the way I did, since I needed to delete a large range of about 100 tickets. But I got this script close enough and then used it to delete tickets in batches of 10. Here is the script I used:

Import-Module SMlets -CMDlet get-scsmclass,get-scsmobject
$IR = 'IR12075*'
$IRClass = Get-scsmclass System.WorkItem.Incident$
$IRsList = Get-SCSMObject -Class $IRClass -Filter "ID -like $IR”
Foreach ($IR in $IRsList) { 
     Remove-SCSMObject $IR -Confirm:$False -Force
}

The only part you need to change is the IR number. The * is the wildcard character and should stay in there unless you want to hard code a ticket number.


Sources:


Share on Google Plus

About Tom DeMeulenaere

Highly accomplished information technology professional with extensive knowledge in System Center Configuration Manager, Windows Server, SharePoint, and Office 365.
    Blogger Comment

0 comments:

Post a Comment

Note: Only a member of this blog may post a comment.