Creating an INC/Incident ticket in BMC ITSM using powershell

by Grzegorz Kulikowski

Hello,
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:
[sourcecode language=”powershell”]
$myitsm=New-WebServiceProxy -Uri http://itsm.midtier.lan/arsys/WSDL/public/itsm.midtier.lan/HPD_IncidentInterface_Create_WS -Namespace ITSM
$ITSMQueryUser=’ourITSMlogin’
$auth= New-Object ITSM.AuthenticationInfo
$auth.username=$ITSMQueryUser
#you can also just simply use: $passwd=’mysecretpasswordformyitsmuser’
$passwd= get-content C:\passwdforouruser.txt | convertto-securestring
$auth.password=[System.Runtime.InteropServices.marshal]::PtrToStringAuto([System.Runtime.InteropServices.marshal]::SecureStringToBSTR($passwd))
$myitsm.AuthenticationInfoValue=$auth
[/sourcecode]
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:
[sourcecode language=”powershell”]
$myitsm.HelpDesk_Submit_Service
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)
[/sourcecode]
Now… it’s really hard to see anything in here… Let’s make it more human readable
[sourcecode language=”powershell”]
$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)
[/sourcecode]
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 :
[sourcecode language=”powershell”]
[enum]::getvalues([ITSM.Reported_SourceType])
DirectInput
Email
ExternalEscalation
Fax
SelfService
SystemsManagement
Phone
VoiceMail
WalkIn
Web
Other
BMCImpactManagerEvent
[/sourcecode]
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.
[sourcecode language=”powershell”]
Incident_Number HPD_CI_ReconID
————— ————–
INC00000001 RE00XXXXXXXXXXXXXXXXXXXXXXXXXX
INC00000002 RE00XXXXXXXXXXXXXXXXXXXXXXXXXX
INC00000003 RE00YYYYYYYYYYYYYYYYYYYYYYYYYY
[/sourcecode]
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
[sourcecode language=”powershell”]
$myitsm.HelpDesk_Submit_Service(
‘MYTEAM’,
$null,
‘MYCOMPANY’,
‘MYORGANIZATION’,
‘Grzegorz Kulikowski’,
$null,
$null,
$null,
$null,
$null,
‘Application’,
‘Server Hardware’,
‘Production’,
$null,
$null,
‘Mega Services’,
‘Grzegorz’,
[ITSM.ImpactType]’Item4MinorLocalized’,
‘Kulikowski’,
$null,
$null,
‘Application’,
‘Server Hardware’,
‘Production’,
$null,
$null,
[ITSM.Reported_SourceType]’Other’,
$null,
$null,
$null,
$null,
[ITSM.Service_TypeType]’UserServiceRestoration’,
[ITSM.StatusType]’InProgress’,
‘CREATE’,
[ITSM.Create_RequestType]’No’,
‘Description’,
‘Notes from test ticket’,
[ITSM.UrgencyType]’Item4Low’,
‘Created from Psapp’,
‘Notes in notes’,
[ITSM.Work_Info_TypeType]’General’,
$date,
[ITSM.Work_Info_SourceType]’Other’,
[ITSM.Create_RequestType]’No’,
[ITSM.Work_Info_View_AccessType]’Internal’,
”,
$null,
$null,
$null,
$null,
$null,
‘Infrastructure Services’,
‘RE00YYYYYYYYYYYYYYYYYYYYYYYYYYYY’,
‘Server Hardware’,
‘RE00XXXXXXXXXXXXXXXXXXXXXXXXX’,
$null,
$null,
$null,
$null,
$null)
[/sourcecode]

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

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 :
https://communities.bmc.com/thread/49687
https://communities.bmc.com/community/bmcdn/bmc_it_service_support/change_process_management/blog/2013/10/18/the-pulse-communicate-effectively-with-change-notifications

Below you can check the body of soap request that i have used to create an INC ticket.
[sourcecode language=”powershell”]
<soapenv:Body>
<urn:HelpDesk_Submit_Service>
<!–1 or more repetitions:–>
<urn:Assigned_Group>MYTEAM</urn:Assigned_Group>
<urn:Assigned_Group_Shift_Name></urn:Assigned_Group_Shift_Name>
<urn:Assigned_Support_Company>MYCOMPANY</urn:Assigned_Support_Company>
<urn:Assigned_Support_Organization>MYORGANIZATION</urn:Assigned_Support_Organization>
<urn:Assignee></urn:Assignee>
<urn:Categorization_Tier_1></urn:Categorization_Tier_1>
<urn:Categorization_Tier_2></urn:Categorization_Tier_2>
<urn:Categorization_Tier_3></urn:Categorization_Tier_3>
<urn:CI_Name>Server Hardware</urn:CI_Name>
<urn:Closure_Manufacturer></urn:Closure_Manufacturer>
<urn:Closure_Product_Category_Tier1></urn:Closure_Product_Category_Tier1>
<urn:Closure_Product_Category_Tier2></urn:Closure_Product_Category_Tier2>
<urn:Closure_Product_Category_Tier3></urn:Closure_Product_Category_Tier3>
<urn:Closure_Product_Model_Version></urn:Closure_Product_Model_Version>
<urn:Closure_Product_Name></urn:Closure_Product_Name>
<urn:Department>MEGA Services</urn:Department>
<urn:First_Name>Grzegorz</urn:First_Name>
<!–1 or more repetitions:–>
<urn:Impact>4-Minor/Localized</urn:Impact>
<urn:Last_Name>Kulikowski</urn:Last_Name>
<urn:Lookup_Keyword></urn:Lookup_Keyword>
<urn:Manufacturer></urn:Manufacturer>
<urn:Product_Categorization_Tier_1>Application</urn:Product_Categorization_Tier_1>
<urn:Product_Categorization_Tier_2>Server Hardware</urn:Product_Categorization_Tier_2>
<urn:Product_Categorization_Tier_3>Production</urn:Product_Categorization_Tier_3>
<!–Optional:–>
<urn:Product_Model_Version></urn:Product_Model_Version>
<urn:Product_Name></urn:Product_Name>
<urn:Reported_Source>Other</urn:Reported_Source>
<urn:Resolution></urn:Resolution>
<urn:Resolution_Category_Tier_1></urn:Resolution_Category_Tier_1>
<urn:Resolution_Category_Tier_2></urn:Resolution_Category_Tier_2>
<urn:Resolution_Category_Tier_3></urn:Resolution_Category_Tier_3>
<urn:Service_Type>Infrastructure Restoration</urn:Service_Type>
<!–1 or more repetitions:–>
<urn:Status>New</urn:Status>
<urn:Action>CREATE</urn:Action>
<urn:Create_Request>NO</urn:Create_Request>
<urn:Summary>Test Summary</urn:Summary>
<urn:Notes>Test Notes</urn:Notes>
<!–1 or more repetitions:–>
<urn:Urgency>4-Low</urn:Urgency>
<urn:Work_Info_Summary>SummaryWRKinfo</urn:Work_Info_Summary>
<urn:Work_Info_Notes>NotesWRKinfo</urn:Work_Info_Notes>
<urn:Work_Info_Type></urn:Work_Info_Type>
<!–1 or more repetitions:–>
<urn:Work_Info_Date>2014-01-28T12:30:00.000+01:00</urn:Work_Info_Date>
<urn:Work_Info_Source>Other</urn:Work_Info_Source>
<urn:Work_Info_Locked>No</urn:Work_Info_Locked>
<urn:Work_Info_View_Access>Internal</urn:Work_Info_View_Access>
<!–1 or more repetitions:–>
<urn:Middle_Initial></urn:Middle_Initial>
<urn:Status_Reason></urn:Status_Reason>
<urn:Direct_Contact_First_Name></urn:Direct_Contact_First_Name>
<urn:Direct_Contact_Middle_Initial></urn:Direct_Contact_Middle_Initial>
<urn:Direct_Contact_Last_Name></urn:Direct_Contact_Last_Name>
<urn:TemplateID></urn:TemplateID>
<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>
<urn:HPD_CI_FormName></urn:HPD_CI_FormName>
<!–Optional:–>
<urn:WorkInfoAttachment1Name>?</urn:WorkInfoAttachment1Name>
<!–Optional:–>
<urn:WorkInfoAttachment1Data>?</urn:WorkInfoAttachment1Data>
<!–Optional:–>
<urn:WorkInfoAttachment1OrigSize>?</urn:WorkInfoAttachment1OrigSize>
</urn:HelpDesk_Submit_Service>
</soapenv:Body>
[/sourcecode]
Don’t forget to fill out the authentication bit :
[sourcecode language=”powershell”]
<urn:AuthenticationInfo>
<urn:userName>ITSMusername</urn:userName>
<urn:password>passwd</urn:password>
[/sourcecode]
Ideally in response in SoapUI you should get something similar to this:
[sourcecode language=”powershell”]
<ns0:HelpDesk_Submit_ServiceResponse xmlns:ns0="urn:HPD_IncidentInterface_Create_WS">
<ns0:Incident_Number>INC0000000111111</ns0:Incident_Number>
</ns0:HelpDesk_Submit_ServiceResponse>
[/sourcecode]
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 :
‘4-Low’
‘4-Minor/Localized’
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.

Advertisements

You may also like

5 comments

John McCabe January 28, 2014 - 9:43 pm

ARGH!!! I needed this 36hours ago! 🙂 but excellent post as it is exactly right… fair play!

BTW this works also for the cloud service BMC OnDemand ITSM

so great work!

Reply
psvmware January 28, 2014 - 10:16 pm

😉 Thanks John

Reply
Adam February 13, 2014 - 12:13 pm

cheers dude helped me out alot here.

Reply
chitransh October 27, 2016 - 6:07 pm

The contact for the creation of an Incident
cannot be found, please verify the contact information and try again

Reply
chitransh October 27, 2016 - 6:09 pm

I am getting this error. Please help anyone.

Reply

Leave a Reply

Chinese (Simplified)DutchEnglishFrenchGermanHindiPolishRussianSpanish