PowerShell/SCSM - Change the Status of a Manual Activity or a Service Request.

2015/01/17 | 1 minute read |

Using the PowerShell module SMlets you can easily change the Status of a Ticket inside System Center Service Manager.

Here are the small bits of code to change the Status of a Manual Activity and a Service Request.

# Import the module
Import-Module -Name smlets

# Get a specific manual activity
$ManualActivity = Get-SCSMObject -Class (Get-SCSMClass -Name System.WorkItem.Activity.ManualActivity$) -filter "ID -eq MA51163"
# Change the status of the Manual Activity
Set-SCSMObject -SMObject $ManualActivity -Property Status -Value Completed

# Get a specific Service Request
$ServiceRequest = Get-SCSMObject -Class (Get-SCSMClass -Name System.WorkItem.ServiceRequest$) -filter "ID -eq SR51160"
# Change the status of the Service Request to Completed
Set-SCSMObject -SMObject $ServiceRequest -Property Status -Value Completed

Status Enumerations

If you want to retrieve all the types of Enumerations and Classes, You can use a very neat tool called SCSM Entity Explorer available on Technet (for Free) created by Dieter Gasser.

SCSM Entity Explorer is a tool for System Center Service Manager (SCSM) administrators to help them browse and get information about the classes, enumerations and objects stored in the SCSM database.

SCSM Entity Explorer allows you to browse classes and relationships in a easy to use tree view and to get all details about the entity types, such as properties and relationships. Using the built-in search, you can find classes and enums very quickly.

SCSM Entity Explorer allows you to retrieve a list of all instances of a class and to view the details of a class instance, including all its properties and related objects. Last but not least you can open the Management Pack which defines your entity type in an XML editor of your choice with one single mouse-click.

</div>

For example, here are the status available for an Activity based on the enumeration information I found in SCSM Entity Explorer.

Then you can retrieve the different status available using Get-SCSMEnumeration

# Retrieve Activity Status
Get-SCSMEnumeration -Name ActivityStatusEnum

</div>

Same thing for the Service Request

# Retrieve Service Request Status
Get-SCSMEnumeration -Name ServiceRequestStatusEnum

Leave a Comment