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
}
$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:
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.