Querying ITSM Incident tickets from Powershell

I have spent few days now in order to get information about tickets that are stored in ITSM. In order to query for INCident ticket in BMC ITSM we need
the uri to the webservice. How to get it ?
Access your internal ITSM server to get list of webservices:

You will be prompted for user and password. Authenticate. After this you will receive a list of Web service name, service type, description. Copy link to
HPD_IncidentInterface_WS . This one will allow us to query our incident tickets.
Should be something like this:
In order to consume it i use this uri:
Replace the ‘protected’ with ‘public’

Open powershell console and do the following:
$myitsm=New-WebServiceProxy -Uri $uri -Namespace ITSM
Let’s complete authentication:

$auth= New-Object ITSM.AuthenticationInfo
$auth.password= [System.Runtime.InteropServices.marshal]::PtrToStringAuto([System.Runtime.InteropServices.marshal]::SecureStringToBSTR($cred.password))

You can always put it in plain text ($auth.username=’myuser’ // $auth.password=’yourpassword’)
Let’s set a INC number that we will be looking for

Let’s build the search criteria

$criteria=”‘Incident Number’ = “”$tid”””

If you would like to build criteria based on your name and surname then it would look like this:
$criteria=”‘First Name’ = “”Grzegorz”” AND ‘Last Name’ = “”Kulikowski”” ”

Ok, lets perform our search. In my case i know that i will only receive 1 INC ticket.
$answer.count -> that will be 1 now as i have only 1 INC in my queue
the method: HelpDesk_QueryList_Service asks for ( search criteria, starting record number, maximum records returned)
i can now open my INC ticket to see what is inside, sample output:

Assigned_Group                 : Greg Team
Assigned_Support_Organization  : Greg Team Org
Assignee                       : Grzegorz Kulikowski
City                           : Monki
Closure_Product_Category_Tier1 : Application
Company                        : Greg S.A
Country                        : Polska
Department                     : IT section
Summary                        : test123
Notes                          : test123
First_Name                     : Grzegorz
Impact                         : {Item4MinorLocalized}
Incident_Number                : INC000000049839
Internet_Email                 : gregua@internety.com
Last_Name                      : Kulikowski
Product_Categorization_Tier_1  : Application
Product_Categorization_Tier_2  : Infrastructure Services
Reported_Source                : {DirectInput}
Service_Type                   : {UserServiceRestoration}
Status                         : {InProgress}
Urgency                        : {Item4Low}
HPD_CI                         : Server

I have listed only few from the properties.

So actually, to run your query this portion of code is enough:

$myitsm=New-WebServiceProxy -Uri http://itsm.midtier.lan/arsys/WSDL/public/itsm.midtier.lan/HPD_IncidentInterface_WS -Namespace ITSM
$auth= New-Object ITSM.AuthenticationInfo
$auth.password= [System.Runtime.InteropServices.marshal]::PtrToStringAuto([System.Runtime.InteropServices.marshal]::SecureStringToBSTR($cred.password))
$criteria="'Incident Number' = ""$tid"""

It does not look scary 😉 Took me some time to figure this out though. In next post i will try to show how to query for Changes and how to update tickets,crqs. Have in mind that i am not ITSM specialist, just end-user of this application. If you have any documents about using itsm web services, please share it in comments.

Useful links:
BMC Remedy IT Service Management 7.0 Integration
Using BMC ITSM OOB Web Service

In case of having issues check this post as well:



5 thoughts on “Querying ITSM Incident tickets from Powershell

  1. Hi Grzegorz. Using your code to connect to ITSM via Powershell I’m not getting any results (the $answer variable remains empty), but using fiddler I’m able to see that both the call and the response from the web service are OK. Do you have any idea why the method isn’t returning any value in powershell? some blogs suggest that it may be something related to namespaces… Also, I’m calling the WS using ssl (https)

  2. Pingback: Querying itsm change requests from powerhsell | VMware and Powershell
  3. Pingback: Creating an INC/Incident ticket in BMC ITSM using powershell | VMware and Powershell
  4. Works using SOAPUI. Your posting gave me the lead. thanks. If anyone looking for the SOAP params in XML





    ‘Incident Number’ = “INC000000378790” OR
    ‘Status’ = “In Progress”

  5. Hi,

    I am working on the same but i am not able to do so. I have tried java code and then got your powershell script. But i am afraid its not working for me.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s