Using SMLets Beta 3 Post #5–Getting the GUID ID of an Object

Using SMLets Beta 3 Post #5–Getting the GUID ID of an Object

Rate This
  • Comments 2

Let’s say you are doing some fancy stuff like manually crafting some notifications like this blog post:

http://blogs.technet.com/servicemanager/archive/2009/12/15/custom-notification-workflow-on-incident-assignement-or-re-assignment.aspx 

…and you want to be able to send the notification to a specific user (or group) using the portion of the rule configuration XML that looks like this:

<WorkflowArrayParameter Name="PrimaryUserList" Type="string">

<Item>d37d441f-20e2-134b-1fea-2f708188bfb2</Item>

</WorkflowArrayParameter>

You need to know the GUID of the user ID to put in the <Item> element. 

How do you get that?  Well – use SMLets of course!  Smile

Here is an easy example:

Get-SCSMObject –Class (Get-SCSMClass –Name System.Domain.User) –Filter “UserName -eq twright” | Format-Table ID, DisplayName

Looks like this:

image

Then you can just copy the GUID right out of the PowerShell window there!

Update: 12/7/2011

If you try to do this for a work item object it won’t behave the same way though because there is a System.WorkItem.Id property that is inherited to all work item classes.  In order to get the GUID ID in that case you need to do a special trick.

image

You can use either the Get_ID() method or the PSObject… approach to get at the underlying object and get the GUID of it.

Leave a Comment
  • Please add 5 and 4 and type the answer here:
  • Post
  • @Travis,

    Are you going to do a post covering Projection as this seems to be the way to get a list of incidents assigned to a particular user.

    I am having some trouble figuring this out.

    F.

  • This works great, as long as the class doesn't define a property called "Id", such as System.WorkItem. I needed to get the Object Guid for a Review Activity, and tried the following:

    Get-SCSMClass -Name System.WorkItem.Activity.ReviewActivity | Get-SCSMObject -Filter "Id -eq -RA4724" | Format-Table ID, DisplayName

    Id                         DisplayName

    --                         -----------

    RA4724                     RA4724: Accept Deployment Build CR

    Can SMLets be used to get the Object Guid of an instance of a class that defines an Id property such as a System.WorkItem?

    TIA,

    Mike

Page 1 of 1 (2 items)