REST API – Forward SCOM alerts into ManageEngine ServiceDesk Plus (IT Assist)

I had a requirement from one of my clients to forward SCOM alerts to ManageEngine ServiceDesk(ITAssist)Plus

I’m using the powershell “Invoke-RestMethod” to call the URL and pass the different values to the URL for the Incident to be logged into ServiceDesk Plus.

Here is the complete script. The script is scheduled in Task Scheduler on the Windows server to run every 130 seconds and look for any new alerts in the last 125 seconds

For each alert that is found the script calls the “new-helprequest” function that creates the URI for ServiceDesk.

#param($alertid)

function new-helprequest{

param(

[string]$technician=”<tech name of user in ServiceDesk>”,

[string]$requester=”SCOM”,

[string]$subject=”<replace this with the alert name or any generic subject>”,

[string][Parameter(Mandatory=$true)]$description,

[string]$category=”<Category in ServiceDesk>”,

[string]$subcategory=”<Subcategory in ServiceDesk>”,

[string]$mode=”Web Form”,

[string]$impact=”Affects User <From Service Desk>”,

[string]$urgency=”Low”,

[string]$priority=”Low”,

[string]$asset=”Low”,

[string]$site=”<Site information in Service Desk>”,

[string]$group=”<Group in Service Desk for assignment of incident>”,

[string]$requesttemplate=”<The template in ServiceDesk>”,

[string]$extension=”<extension number of technician in ServiceDesk”)

#this is an xml template to generate new SDP requests

$requestXML=[xml](“<Operation>

<Details>

<technician></technician>

<requester></requester>

<subject></subject>

<description></description>

<mode></mode>

<category></category>

<subcategory></subcategory>

<impact></impact>

<urgency></urgency>

<priority></priority>

<site></site>

<asset></asset>

<group></group>

<requesttemplate></requesttemplate>

<extension></extension>

</Details>

</Operation>”)

$url = “<>” #url to your helpdesk server

$api = “<>” #api path, which is pretty much the same for SDP 8+

$operation = “ADD_REQUEST” #the operation

$apiKey = “<Api of the technician account defined above>” #the api key you generated from one of your technician accounts.

#Configure the parameters for the xml with the content from the command parameters

$requestXML.operation.details.technician= $technician

$requestXML.operation.details.requester = $requester

$requestXML.operation.details.subject = $subject

$requestXML.operation.details.description = $description

$requestXML.operation.details.category = $category

$requestXML.operation.details.mode = $mode

$requestXML.operation.details.subcategory = $subcategory

$requestXML.operation.details.impact = $impact

$requestXML.operation.details.urgency = $urgency

$requestXML.operation.details.priority = $priority

$requestXML.operation.details.site = $site

$requestXML.operation.details.group = $group

$requestXML.operation.details.asset = $asset

$requestXML.operation.details.requesttemplate = $requesttemplate

$requestXML.operation.details.extension = $extension

$uri = $url + $api + “OPERATION_NAME=” + $operation + “&TECHNICIAN_KEY=” + $apiKey + “&INPUT_DATA=” + $requestXML.InnerXml #assemble a URI. SDP expects a paramatized URI method to generate requests.

#write-host $uri

Invoke-RestMethod -Method post -Uri $uri

}

#Creates a text file for troubleshooting

add-content -Path c:servicedeskoutput.txt -Value “Started the run”

#$alertid=$alertid.tostring()

#Import-Module OperationsManager

add-pssnapin “Microsoft.EnterpriseManagement.OperationsManager.Client”

new-managementgroupconnection -ConnectionString:<MSServerName>

set-location “OperationsManagerMonitoring::”

#$alert = Get-SCOMAlert -Id $alertid

$todaydate = get-date

add-content c:servicedeskoutput.txt $todaydate

#The criteria below is specific to my requirement where I’m looking for a devices with specific words in the Path of the object

#You can change the criteria for your application

$alerts = get-alert | where {$_.Timeraised -ge $todaydate.addminutes(-125) -and $_.MonitoringObjectPath -like ‘*<domainname>*’ -and $_.ResolutionState -ne 255}

foreach ($alert in $alerts)

{

add-content c:servicedeskoutput.txt $alert.description

#$alert = Get-Alert -Id $alertid

$alertdescription =$alert.description

$alertname = $alert.name

$alertseverity = $alert.severity

$alertpriority = $alert.priority

#The steps below maps the SCOM alert severity to the severities in ServiceDesk Plus

if ($alertseverity -eq “Error”) { $alertseverity = “Critical” }

if ($alertseverity -eq “Warning”) { $alertseverity = “High” }

#write-host $alertseverity

$computername = $alert.NetBiosComputerName

if (!$computername)

{

$computername=$alert.MonitoringObjectDisplayName

}

else

{

$computername=$alert.PrincipalName

}

$computernamefqdn = $computername

$where = $computername.indexof(“.”)

$computername=$computername.substring(0,$where)

[xml] $a = new-helprequest -requester “SCOM” -subject “$computername – $alertname” -asset $computernamefqdn -urgency “$alertseverity” -priority “$alertpriority” -description “$alertdescription” -group “<ServiceDesk GroupName>” -requesttemplate “Default Request”

}

Screenshot of the Requests as they appear in ServiceDesk

 

Advertisements

2 thoughts on “REST API – Forward SCOM alerts into ManageEngine ServiceDesk Plus (IT Assist)

  1. Hello , I need some help concerning this subject can I have your email ?

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