Xapity Blog

PowerShell for SCSM: Activity Status - Skip, Complete, Rerun


This blog post will cover how to change the status of a manual or review activity via PowerShell. This can be very powerful in an activity workflow on an SCSM Service Request (SR) or Change (CR).

By using a Xapity PowerShell Activity as the first item in the activity workflow, you can use data entered in the parent work item to determine if the predefined template activities should run or not. This allows more generic templates where the activities that run are determines by what was filled out on the change or service request.

Activities can have the following status values:

  • Completed

  • Cancelled

  • Skipped

  • In Progress

  • On Hold

  • Failed

  • Rerun

  • Pending

Activity Enumerations

The Activity status values are stored as Activity Enumerations and you can list them with the PowerShell Command:


DisplayName Name Id ----------- ---- -- Completed ActivityStatusEnum.Completed 9de908a1-d8f1-477e-c6a2-62697042b8d9 Cancelled ActivityStatusEnum.Cancelled 89465302-2a23-d2b6-6906-74f03d9b7b41 Skipped ActivityStatusEnum.Skipped eaec5899-b13c-d107-3e1a-955da6bf9fa7 In Progress ActivityStatusEnum.Active 11fc3cef-15e5-bca4-dee0-9c1155ec8d83 On Hold ActivityStatusEnum.OnHold d544258f-24da-1cf3-c230-b057aaa66bed Failed ActivityStatusEnum.Failed 144bcd52-a710-2778-2a6e-c62e0c8aae74 Rerun ActivityStatusEnum.Rerun baa948b5-cc6a-57d7-4b56-d2012721b2e5 Pending ActivityStatusEnum.Ready 50c667cf-84e5-97f8-f6f8-d8acd99f181c Activity Status ActivityStatusEnum 57db4880-000e-20bb-2f9d-fe4e8aca3cf6​


Change Activity Status to Completed

To change the status of the activity you will need to retrieve the MA or RA object. Then use the Set-SCSMObject to set the status property to Completed.

When this is done in the console a dialog asks for a comment and this is appended to the notes field on both the RA and MA. On the RA the notes field is not displayed on the default form, but you can see it in the history audit.


Change Activity Status to Skipped

It is a similar command as above to put an activity into skipped status. This time we change the Skip property on the activity object to true.


Return to Activity

To return to the manual or review activity we have to set the Skip property to false and use the Rerun status to return to the activity.


Further extensions

Skipped activities will still register against the assigned team. It would be possible to either:

  • Reassign the activity in the PowerShell script

  • delete the activity via the PowerShell script.

#PowerShell #PowerShellActivity

Featured Posts
Recent Posts
Archive
Search By Tags
No tags yet.

© 2020 Xapity PTY LTD ABN: 81 611 883 482

  • White RSS Icon
  • White YouTube Icon
  • White Vimeo Icon
  • Facebook Clean
  • Twitter Clean