Getting incident notes from Remedy using ARAPI.NET from PowerShell

Here is another example of using ARAPI.NET from PowerShell. This is a script I wrote and use every day to retrieve notes from a Remedy Incident. As a manager, I rarely use Remedy to work incidents. However, I frequently need to review the notes and ensure that incidents are being resolved efficiently. Logging into Remedy, finding the incident, and reviewing all of the notes can be a time-consuming process. This script makes it very easy for me to quickly see all of the notes and provide status updates to my management.

All I need is the incident number. Using the incident number passed on the command line the script searches the HPD:Search-Worklog form for Work Log entries for the specified Incident.

The output looks like this:

PS E:\> .\get-incident.ps1 IR0000000183197
===============================
incident      : IR0000000183197
submitdate    : 4/28/2015 8:22:47 AM
customer      : serverops
workphone     : 1 206 555-1212
source        : Systems Management
servicetype   : Monitoring Event
status        : Assigned
assignedgroup : Windows OS
assignee      :
opcat1        : Business Process
opcat2        :
opcat3        :
prodcat1      : Software
prodcat2      : Operating System
prodcat3      : Server OS
impact        : Moderate
urgency       : Medium
priority      : Medium
summary       : server1.contoso.net Logical disk C: on host server1.contoso.net has 10 % free space remaining.
notes         :

-------------------------------
date        : 4/28/2015 8:22:42 AM
submitter   : remedyuser15
logtype     : General Information
Attachment1 :
Attachment2 :
Attachment3 :
description : Alert Info for Ticketing:
              host: server1.contoso.net
              Severity: MINOR
              Message: Logical disk C: on host server1.contoso.net has 10 % free space remaining.
              Object: C:
              ITSM Queue: Windows OS
              Modified: 4/28/2015 8:12:19 AM
===============================

The pattern of the script is the same as my previous examples. I set up the parameters (which can be overridden on the command line) to connect to the Remedy application server. Then I define the field IDs that I want to retrieve. I also define some string dictionaries that I use to convert numeric values returned by Remedy into the text values that are displayed by the mid-tier.

param ($searchTerm,
       $fieldID=1000000161,
       $appServer = "appserver.contoso.net",
       $svcAccount = "remedyuserid",
       $svcPassword = "remedypassword",
       $remAuthDomain = "",
       $arSrvrPort = 51100,
       $formName = "HPD:Search-Worklog")

add-type -path 'C:\Program Files (x86)\BMC Software\ARAPI80.NET\BMC.ARSystem.dll'

$incFields = @{         7="Status         ";
                200000003="ProdCat 1      ";
                200000004="ProdCat 2      ";
                200000005="ProdCat 3      ";
               1000000000="Description    ";
               1000000018="Last Name      ";
               1000000019="First Name     ";
               1000000056="Phone Number   ";
               1000000063="OpCat 1        ";
               1000000064="OpCat 2        ";
               1000000065="OpCat 3        ";
               1000000099="Service Type   ";
               1000000151="Decription     ";
               1000000161="Incident Number";
               1000000162="Urgency        ";
               1000000163="Impact         ";
               1000000164="Priority       ";
               1000000215="Source         ";
               1000000217="Assigned Group ";
               1000000218="Assignee       ";
               1000000422="Owner Group    ";
               1000000560="Reported Date  ";
               1000000881="Status Reason  ";
               1000005782="Contact Last   ";
               1000005783="Contact First  ";
               1000005785="Contact Phone  ";
              }

$wlFields = @{  301394441="Description    ";
               1000000157="Submit Date    ";
               1000000159="Submitter      ";
               1000000170="Work Log Type  ";
               1000000351="Attachment01   ";
               1000000352="Attachment02   ";
               1000000353="Attachment03   ";
               1000002134="Work Log Date  ";
               1000003610="Summary        ";
             }
$arserver = new-object BMC.ARSystem.Server
$arserver.Login($appServer, $svcAccount, $svcPassword, $remAuthDomain, $arSrvrPort)
$qualifier = "'{0}' = ""{1}""" -f $fieldID,$searchTerm

[BMC.ARSystem.EntryListFieldList] $formEntryFieldList = new-object BMC.ARSystem.EntryListFieldList
$incFields.Keys | %{ $formEntryFieldList.AddField($_) }
$wlFields.Keys  | %{ $formEntryFieldList.AddField($_) }

$impactvalues = @{ 1000="Extensive"; 2000="Significant"; 3000="Moderate"; 4000="Minor" }
$urgencyvalues = @{ 1000="Critical"; 2000="High"; 3000="Medium"; 4000="Low" }
$priorityvalues = @{ 0="Critical"; 1="High"; 2="Medium"; 3="Low" }
$statusvalues = @{ 0="New"; 1="Assigned"; 2="In Progress"; 3="Pending"; 4="Resolved"; 5="Closed"; 6="Cancelled"; }
$servicevalues = @{ 0="User Restoration"; 1="User Service Request"; 2="System Restoration"; 3="Monitoring Event"; }
$sourcevalues =  @{ 1000="Direct Input"; 2000="Email"; 3000="External Escalation"; 4000="Fax"; 4200="Self Service"; 5000="Systems Management"; 6000="Phone"; 7000="Voice Mail"; 8000="Walk In"; 9000="Web"; 10000="Other"; 11000="BMC Impact Manager Event"; }
$worklogtypes = @{
   1000="----- Customer Inbound -----";
   2000="Customer Communication";
   3000="Customer Follow-up";
   4000="Customer Status Update";
   5000="----- Customer Outbound -----";
   6000="Closure Follow Up";
   7000="Detail Clarification";
   8000="General Information";
   9000="Resolution Communications";
   10000="Satisfaction Survey";
   11000="Status Update";
   12000="----- General -----";
   13000="Incident Task / Action";
   14000="Problem Script";
   15000="Working Log";
   16000="Email System";
   17000="Paging System";
   18000="BMC Impact Manager Update";
   35000="Chat";
   36000="B2B Vendor Update";
 }

[BMC.ARSystem.EntryFieldValueList] $fieldValues = $arserver.GetListEntryWithFields($formName, $qualifier, $formEntryFieldList, 0, 0);
$irfields = $fieldValues[0].fieldvalues

$irheader = [ordered]@{
               incident     =$irfields[1000000161];
               customer     =$irfields[1000000019] + " " + $irfields[1000000018];
               workphone    =$irfields[1000000056];
               source       =$sourcevalues[$irfields[1000000215]];
               servicetype  =$servicevalues[$irfields[1000000099]];
               status       =$statusvalues[$irfields[0000000007]];
               assignedgroup=$irfields[1000000217];
               assignee     =$irfields[1000000218];
               opcat1       =$irfields[1000000063];
               opcat2       =$irfields[1000000064];
               opcat3       =$irfields[1000000065];
               prodcat1     =$irfields[0200000003];
               prodcat2     =$irfields[0200000004];
               prodcat3     =$irfields[0200000005];
               impact       =$impactvalues[$irfields[1000000163]];
               urgency      =$urgencyvalues[$irfields[1000000162]];
               priority     =$priorityvalues[$irfields[1000000164]];
               summary      =$irfields[1000000000];
               notes        =$irfields[1000000151];
             }

"==============================="
new-object -type PSObject -prop $irheader             

foreach ($wl in $fieldvalues) {
   "-------------------------------"
   #$wlFields.Keys | %{ "[{0:0000000000}] {1} = {2}" -f $_,$wlFields[$_],$wl.fieldvalues[$_].tostring() }
   $wldata = [ordered]@{
                date        = $wl.fieldvalues[1000002134];
                submitter   = $wl.fieldvalues[1000000159];
                logtype     = $worklogtypes[$wl.fieldvalues[1000000170]];
                Attachment1 = $wl.fieldvalues[1000000351];
                Attachment2 = $wl.fieldvalues[1000000352];
                Attachment3 = $wl.fieldvalues[1000000353];
                description = $wl.fieldvalues[0301394441];
             }
   new-object -type PSObject -prop $wldata
}
"==============================="

$arserver.Logout()

I am an experienced IT technologist specializing in optimizing user experiences, providing best-in-class support and developing creative solutions. I script therefore I am. I build tools to improve troubleshooting and gather supporting data.

Tagged with: ,
Posted in ARAPI, PowerShell

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 )

Google photo

You are commenting using your Google 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 )

Connecting to %s

sean on it
Categories
Follow Sean on IT on WordPress.com
Blog Stats
  • 59,509 hits
Mike F Robbins

Scripting | Automation | Efficiency

%d bloggers like this: