Q: How can I delete all of a certain type of work item from my System Center Service Manager (SCSM) test environment?
June 30, 2011
A: I often want to reset my SCSM demo environment to remove all change requests and incidents from previous demos so that my environment is clean for the next demo. This is possible using the SMLets PowerShell module for Service Manager, as documented in the FAQ "Q: Is there PowerShell support for System Center Service Manager?" Once the cmdlets are loaded, you can list all of a certain type of work item, such as Change Request, using the command
PS C:> Get-SCSMObject -class (get-scsmclass -name system.workitem.changerequest$)
ClassName DisplayName LastModified
--------- ----------- ------------
System.WorkItem.ChangeRequest CR7: Install CopyPicture 6/3/2011 4:04:00 PM
System.WorkItem.ChangeRequest 19: Install CopyPicture 6/3/2011 4:12:24 PM
System.WorkItem.ChangeRequest CR23: Install CopyPicture 6/3/2011 4:17:25 PM
System.WorkItem.ChangeRequest CR48: Install CopyPicture 6/4/2011 9:15:31 AM
System.WorkItem.ChangeRequest CR51: Install CopyPicture 6/4/2011 9:15:25 AM
System.WorkItem.ChangeRequest CR54: Install CopyPicture 6/4/2011 9:49:15 AM
To remove them, just pass the output to the remove-scsmobject -force command:
PS C:> Get-SCSMObject -class (get-scsmclass -name system.workitem.changerequest$) | remove-scsmobject -force
If you want to delete all incidents, change changerequest$ to incident$. To delete all problems, change it to problem$.
About the Author
You May Also Like