Querying itsm change requests from powershell

by Grzegorz Kulikowski

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 ?

[sourcecode language=”powershell”]

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:

[sourcecode language=”powershell”]



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 -> latkin.org.
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:

[sourcecode language=”powershell”]
#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 = "’ASGRP’ = ""$TeamName"" AND ‘Change Request Status’ != ""Cancelled"" AND ‘Change Request Status’ != ""Closed"" AND ‘Change Request Status’ != ""Completed"" AND ‘Change Request Status’ != ""Rejected"" "
$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 |% {"$($_.Name) has $($_.Count) change requests assigned."}

#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:


You may also like


john January 26, 2014 - 12:41 am

Can you give an example for using direct info from an enum because I can’t casting errors and not sure what the problem is

john January 26, 2014 - 12:43 am

Cannot convert argument “Impact”, with value: “Item4MinorLocalized”, for “HelpDesk_Submit_Service” to type
“System.Nullable`1[ITSM.ImpactType]”: “Cannot convert value “Item4MinorLocalized” to type “ITSM.ImpactType”. Error:
“Invalid cast from ‘ITSM.ImpactType’ to ‘ITSM.ImpactType’.””

psvmware January 27, 2014 - 9:32 am

Hi John, first of all, i was not describing yet how to create a INC ticket, will do that soon though. In your case are you using [ITSM.ImpactType]’Item4MinorLocalized’ as the argument ? or just ‘Item4MinorLocalized’ ?

Creating an INC/Incident ticket in BMC ITSM using powershell | VMware and Powershell January 28, 2014 - 9:11 pm

[…] I assume that from previous posts you already know how to consume this webservice from powershell (post1,post2) Let’s start our session […]

Phil December 15, 2015 - 3:44 pm

Hi there,
Can you help me with how to query the Change_Query_Service method? I can’t seem to work out how to supply the CRQ number into this and have it search. Error I always get is like this:

“Cannot find an overload for “Change_Query_Service” and the argument count:”

Thanks for the awesome post. Very Helpful.

psvmware December 16, 2015 - 12:52 pm

Are you passing any arguments to that method ? I can’t remember from top of my head, but i think you need to pass the criteria to it. Can’t you try to use the method i have described here?


Leave a Reply

Chinese (Simplified)EnglishFrenchGermanHindiPolishSpanish
Streaming live on Twitch right now.