Creating an INC/Incident ticket in BMC ITSM using powershell

this time we will create an ITSM INC ticket using the HPD_IncidentInterface_Create_WS web service.
I assume that from previous posts you already know how to consume this webservice from powershell (post1,post2)
Let’s start our session first:

$myitsm=New-WebServiceProxy -Uri http://itsm.midtier.lan/arsys/WSDL/public/itsm.midtier.lan/HPD_IncidentInterface_Create_WS -Namespace ITSM
$auth= New-Object ITSM.AuthenticationInfo
#you can also just simply use: $passwd='mysecretpasswordformyitsmuser'
$passwd= get-content C:\passwdforouruser.txt | convertto-securestring

At this point we can start creating our incident ticket in ITSM using HelpDesk_Submit_Service method from $itsm web service object.
Let’s first read what is required to be sent, by the way, it is required to fill out all arguments. I saw a lot of posts on bmc communities that people had issues because they have missed some field. When building arguments for this method it might be little complicated, because of the number of them. In my case i had to fill out 60 arguments. It might be different for your environment i suppose. Lets inspect the method first:

string HelpDesk_Submit_Service(string[] Assigned_Group, string Assigned_Group_Shift_Name, string Assigned_Support_Company, string Assigned_Support_Organization, string Assignee, string
Categorization_Tier_1, string Categorization_Tier_2, string Categorization_Tier_3, string CI_Name, string Closure_Manufacturer, string Closure_Product_Category_Tier1, string
Closure_Product_Category_Tier2, string Closure_Product_Category_Tier3, string Closure_Product_Model_Version, string Closure_Product_Name, string Department, string First_Name,
System.Nullable[ITSM.ImpactType][] Impact, string Last_Name, string Lookup_Keyword, string Manufacturer, string Product_Categorization_Tier_1, string Product_Categorization_Tier_2, string
Product_Categorization_Tier_3, string Product_Model_Version, string Product_Name, System.Nullable[ITSM.Reported_SourceType] Reported_Source, string Resolution, string Resolution_Category_Tier_1,
string Resolution_Category_Tier_2, string Resolution_Category_Tier_3, System.Nullable[ITSM.Service_TypeType] Service_Type, ITSM.StatusType[] Status, string Action,
System.Nullable[ITSM.Create_RequestType] Create_Request, string Summary, string Notes, System.Nullable[ITSM.UrgencyType][] Urgency, string Work_Info_Summary, string Work_Info_Notes,
System.Nullable[ITSM.Work_Info_TypeType] Work_Info_Type, System.Nullable[datetime][] Work_Info_Date, System.Nullable[ITSM.Work_Info_SourceType] Work_Info_Source,
System.Nullable[ITSM.Create_RequestType] Work_Info_Locked, System.Nullable[ITSM.Work_Info_View_AccessType] Work_Info_View_Access, string[] Middle_Initial, System.Nullable[ITSM.Status_ReasonType]
Status_Reason, string Direct_Contact_First_Name, string Direct_Contact_Middle_Initial, string Direct_Contact_Last_Name, string TemplateID, string ServiceCI, string ServiceCI_ReconID, string HPD_CI,
string HPD_CI_ReconID, string HPD_CI_FormName, string WorkInfoAttachment1Name, byte[] WorkInfoAttachment1Data, int WorkInfoAttachment1OrigSize, bool WorkInfoAttachment1OrigSizeSpecified)

Now… it’s really hard to see anything in here… Let’s make it more human readable

$myitsm.HelpDesk_Submit_Service -split ','
string HelpDesk_Submit_Service(
 string[] Assigned_Group
 string Assigned_Group_Shift_Name
 string Assigned_Support_Company
 string Assigned_Support_Organization
 string Assignee
 string Categorization_Tier_1
 string Categorization_Tier_2
 string Categorization_Tier_3
 string CI_Name
 string Closure_Manufacturer
 string Closure_Product_Category_Tier1
 string Closure_Product_Category_Tier2
 string Closure_Product_Category_Tier3
 string Closure_Product_Model_Version
 string Closure_Product_Name
 string Department
 string First_Name
 System.Nullable[ITSM.ImpactType][] Impact
 string Last_Name
 string Lookup_Keyword
 string Manufacturer
 string Product_Categorization_Tier_1
 string Product_Categorization_Tier_2
 string Product_Categorization_Tier_3
 string Product_Model_Version
 string Product_Name
 System.Nullable[ITSM.Reported_SourceType] Reported_Source
 string Resolution
 string Resolution_Category_Tier_1
 string Resolution_Category_Tier_2
 string Resolution_Category_Tier_3
 System.Nullable[ITSM.Service_TypeType] Service_Type
 ITSM.StatusType[] Status
 string Action
 System.Nullable[ITSM.Create_RequestType] Create_Request
 string Summary
 string Notes
 System.Nullable[ITSM.UrgencyType][] Urgency
 string Work_Info_Summary
 string Work_Info_Notes
 System.Nullable[ITSM.Work_Info_TypeType] Work_Info_Type
 System.Nullable[datetime][] Work_Info_Date
 System.Nullable[ITSM.Work_Info_SourceType] Work_Info_Source
 System.Nullable[ITSM.Create_RequestType] Work_Info_Locked
 System.Nullable[ITSM.Work_Info_View_AccessType] Work_Info_View_Access
 string[] Middle_Initial
 System.Nullable[ITSM.Status_ReasonType] Status_Reason
 string Direct_Contact_First_Name
 string Direct_Contact_Middle_Initial
 string Direct_Contact_Last_Name
 string TemplateID
 string ServiceCI
 string ServiceCI_ReconID
 string HPD_CI
 string HPD_CI_ReconID
 string HPD_CI_FormName
 string WorkInfoAttachment1Name
 byte[] WorkInfoAttachment1Data
 int WorkInfoAttachment1OrigSize
 bool WorkInfoAttachment1OrigSizeSpecified)

Little bit better 😉 Few reminders here, when you will fill this out, make sure you stick to proper type as well. If it is required to type a string for property X we type ‘some value’. If it is required to give values for Reported_Source we need to make sure that we are giving the proper type of reported source like in this example :


So if we will be giving this argument we will be giving it as : methodX(arg1,arg2,[ITSM.Reported_SourceType]’Phone’,argN) for example.
Again i would recommend checking bmc communities in case of issues while doing this, i found there a lot of great tips and documents, links are mentioned in previous post. A must see is document written by Carl Wilson (Using BMC ITSM OOB Web Services.doc (check links section in previous posts). I had to type bit more in my case, but i guess everybody might have to fill out his arguments in a little different way.Anyway…
For me the best way for first time to fill out arguments was to create a spreadsheet document with 2 colums, in first i have the definition in second i type my values. It looks like this:
itsm powershell
We can fill it out now with less chance on making an error by putting value in wrong place. In my case i could not create an INC ticket without filling out the HPD_CI/HPD_CI_RecondID,ServiceCI,ServiceCI_RecondID. In order to fill this out you need to take a look at existing INC ticket, if you want to make a ticket like that just copy those values. In previous post i wrote how to query INC tickets so now we just need to take value from it.

Incident_Number        HPD_CI_ReconID
---------------        --------------

Now when copying those values for HPD_CI_ReconID for example, they are unique for a kind of INC ticket. So if you want to make a ticket that looks like existing ticket Z in your itsm, then just copy values from his properties. Those values are not the same for all kinds of tickets. I have created myself 5 identical tickets with different summaries/descriptions, they all had the same HPD_CI_ReconID. Same goes for ServiceCI/ServiceCI_ReconID. Please have in mind that i don’t have any administrative knowledge of itsm, i’m just end user. Please correct me in comments if i write something here which is not true. All of this was created by making hundreds of attempts via powershell/soap ui.

Also the easiest way just to create a look a like ticket is first to grab him and inspect via powershell so you know which values to put in the request method.
Below is the code for HelpDesk_Submit_Service that i have used for creating simple INC ticket. It has a variable inside $date, which is $date=get-date

'Grzegorz Kulikowski',
'Server Hardware',
'Mega Services',
'Server Hardware',
'Notes from test ticket',
'Created from Psapp',
'Notes in notes',
'Infrastructure Services',
'Server Hardware',

If you will execute this method in return you will get a INCnumber of the ticket that you have created.
In the response we get the INC ticket number. In this picture i just cut out the code as it would be too big ;).

Some other things, when you create the ticket like i do here, you will notice that i am putting it to In progress state, as i can’t put it in new for myself as myself, it can be either in pending or in progress. That should not be the problem if you would not assign it to anybody or to somebody else than you. If you get stuck i recommend to write this in soap ui. Links that might be useful :

Below you can check the body of soap request that i have used to create an INC ticket.

         <!--1 or more repetitions:-->
         <urn:CI_Name>Server Hardware</urn:CI_Name>
         <urn:Department>MEGA Services</urn:Department>
         <!--1 or more repetitions:-->
         <urn:Product_Categorization_Tier_2>Server Hardware</urn:Product_Categorization_Tier_2>
         <urn:Service_Type>Infrastructure Restoration</urn:Service_Type>
         <!--1 or more repetitions:-->
         <urn:Summary>Test Summary</urn:Summary>
         <urn:Notes>Test Notes</urn:Notes>
         <!--1 or more repetitions:-->
         <!--1 or more repetitions:-->
         <!--1 or more repetitions:-->
         <urn:ServiceCI>Infrastructure Services</urn:ServiceCI>
         <urn:ServiceCI_ReconID>---I have copied this value from existing ticket---</urn:ServiceCI_ReconID>
         <urn:HPD_CI>Server Hardware</urn:HPD_CI>
         <urn:HPD_CI_ReconID>---I have copied this value from existing ticket---</urn:HPD_CI_ReconID>

Don’t forget to fill out the authentication bit :


Ideally in response in SoapUI you should get something similar to this:

      <ns0:HelpDesk_Submit_ServiceResponse xmlns:ns0="urn:HPD_IncidentInterface_Create_WS">

One more thing about the soap request. Make sure that you put the values in some fields as you see them in webform and not how powershell is returning them. An example here would be :
We have to type it as ‘4-Low’ and not [ITSM.UrgencyType]—>’Item4Low’, or ‘4-Minor/Localized’ and not [ITSM.ImpactType]—>’Item4MinorLocalized’, like we typed when we were doing this via powershell.

I hope this post will help you to start creating incident tickets in ITSM from powershell using its webservices. If anything is unclear let me know, although like i have mentioned earlier i am no itsm specialist.

vBeers 5th February in Cracow, PL!

If you are planning to be in Cracow on 5th of February and expect to be thirsty 😉 Join us @ vBeer
Location: pub Omerta
Address: Krakow, Kazimierz, ul. Kupa 3, Poland
Date: 05.02.2014
Time: 20:00 (08:00 PM)
more details:
See you there!

Querying itsm change requests from powershell

id addition ton querying-itsm-incident-tickets-from-powershell post..

Let’s start this time from a link… it will save us A LOT ! of time later on. I found this document of bmc communities :
BMC Remedy IT Service Management 7.0 Integrations.pdf
So i advise to go trough this document again even briefly, when you will be building criteria for queries it might save you some time. One more useful thing. When you will be doing those criteria for finding the right crqs use the field names as they are described in the first column in the document ‘DB field on interface form’. Now let’s do some searching.
all changes that belong to team X and they are in status Y and Z
What if we don’t know the value of the possible status values ?


Same goes for other attributes:
I have a list of ITSM change request in my $answer array variable. I have some change in $answer[3]
I want to know what was the reason for status. Let’s check it, in order to do that we need display its property called Status_Reason.
Ok, it means that this change was closed as it was successful. What if we would like to build later on a criteria with status reason of something else like Successful but with some issues ? We would first need to know what are the value possibilities of this field so again:


This time as a argument for GetValues method from Enum class i use directly the type that is used by status reason(using the gettype method on that property). You can read more about enum class on msdn and for example here ->
That said we should be able to construct our criteria as we want.. So how about making one that will:
1) Show only CRQs assigned to our team and active
2) CRQs should not be closed nor cancelled/ closed/ completed/ rejected
Using method Change_QueryList_Service we will get CRQs that match our search criteria. Remember to user proper filed names as per the document from the beggining of this post.
Similar to what i wrote in the post about incidents:

#in case you want to store password for the username you would first need to export it to file for example
#read-host -assecurestring | convertfrom-securestring | out-file C:\x\y\z\generatedpassword.txt
$myitsmCRQ=New-WebServiceProxy -Uri http://itsm.midtier.lan/arsys/WSDL/public/itsm.midtier.lan/CHG_ChangeInterface_WS -Namespace ITSMCRQ
$authCRQ=New-Object ITSMCRQ.AuthenticationInfo
$passwd= get-content C:\x\y\z\generatedpassword.txt | convertto-securestring
$criteriaCRQ = &quot;'ASGRP' = &quot;&quot;$TeamName&quot;&quot; AND 'Change Request Status' != &quot;&quot;Cancelled&quot;&quot; AND 'Change Request Status' != &quot;&quot;Closed&quot;&quot; AND 'Change Request Status' != &quot;&quot;Completed&quot;&quot; AND 'Change Request Status' != &quot;&quot;Rejected&quot;&quot; &quot;
$CRQPeopleStats = $CRQTickets |Group-Object -Property Assignee |Where-Object {($_.Name)}| select Count, @{n='Name';e={$($_.Values)}}

#You can do then for example enumaration through people in those crqs like:

$CRQPeopleStats |% {&quot;$($_.Name) has $($_.Count) change requests assigned.&quot;}

#we should get something similar to this:

#John Kowalski has 4 change requests assigned.
#Robert Zimowski has 2 change requests assigned.
#Cathrine Powerszelska has 12 change requests assigned.
#Thomas Itsmowski has 6 change requests assigned.
#We could also generate a nice table:

$CRQTickets | Select Infrastructure_Change_ID, Summary, @{n='CreatedBY';e={$_.First_Name+' '+$_.Last_Name}}, @{n='CRQ Coordinator';e={$_.Change_Coordinator[0]}}

Infrastructure_Change_ID  Summary                      CreatedBY             CRQ Coordinator
CRQ000034215209           Wazny update do wykonania    Grzegorz Kulikowski   Grzegorz Kulikowski
CRQ000012159912           Paczowanie paczek            Grzegorz Powerszelski Grzegorz Kulikowski

I hope this post will make it easier to get started with querying itsm tickets either incident or change request tickets via powershell.

You can also have a look at that post if you are having issue with querying: