Idera Alert – Powershell – Create Jira Ticket

by Oct 15, 2019

This is a sample of how I am creating Jira Tickets from Idera SQLDM.  I could not find anything on the internet.

#Install-Module JiraPS
#Install DNSClient Client module (Windows 10 and Server 2016)

#PowerShell Action command in Idera .D:JiraPSJiraPS.PS1 -AlertSummary "$(AlertSummary)" -AlertText "$(AlertText)" -Metric "$(Metric)"-Severity "$(Severity)" -Instance "$(Instance)" -Database #"$(Database)" -Timestamp #"$(Timestamp)" -Value "$(Value)" -Description "$(Description)" -Resource "$(Resource)"

#Test .JiraPS.PS1 -AlertSummary "Test AlertSummary" -AlertText "Test AlertText" -Metric "Test Metric"

param (
[string]$AlertSummary = $null,
[string]$AlertText = $null,
[string]$Metric = $null,
[string]$Severity = $null,
[string]$Instance = $null,
[string]$Database = $null,
[string]$Timestamp = $null,
[string]$Value = $null,
[string]$Description = $null,
[string]$Resource = $null)

if ((Get-Module -ListAvailable -name DNSClient ) -and ($instance)){
$servername = Resolve-DnsName -name $Instance | Select NameHost

$Text = "AlertSummary: $AlertSummary`r`n"
$Text+= "AlertText: $AlertText`r`n"
$Text += "Severity: $Severity`r`n"
$Text += "Instance: $Instance`r`n"
$Text += "Servername: $($Servername.namehost)`r`n"
$Text += "Database: $Database`r`n"
$Text += "Timestamp: $Timestamp`r`n"
$Text += "Value: $Value`r`n"
$Text += "Description: $Description`r`n"
$Text += "Resource: $Resource`r`n"

Set-JiraConfigServer -Server "https://*JiraSite*/"
$Username = "*JiraUserName*"

##To set the password login in with AD account that is running Idera service.  Create the password using the below.  That profile will be able to decrypt the password.  

##Set Password for confluence
##$File = "\Machine1SharedPathPassword.txt"
##$Password = "P@ssword1" | ConvertTo-SecureString -AsPlainText -Force
##$Password | ConvertFrom-SecureString | Out-File $File

##Use Password
$encrypted = Get-Content D:JiraPSPasswordPassword.txt | ConvertTo-SecureString
$Cred = New-Object System.Management.Automation.PsCredential($username, $encrypted)
Get-JiraIssueCreateMetadata -Project DBA -IssueType Task -Credential $cred
$Jiraresults = New-JiraIssue -Project DBA -IssueType Task -Summary "Idera: $AlertSummary" -Description "$Text" -Credential $cred

$Text += "Jiraresults: $Jiraresults`r`n"

$timer = (Get-Date -Format yyy-mm-dd-hhmmss)
$Text | Out-File "D:JiraPSlogtest_$($timer).txt"

$From = ""
$To = ""
$attachment = "D:JiraPSlogtest_$($timer).txt""
$Subject = "Idera Monitoring Jira Ticket $Jiraresults"
$Body = "$Text"
$SMTPServer = ""
$SMTPPort – "25"
Send-MailMessage -From $from -To $To -Subject $Subject -Body $Body -SMTPServer $SMTPServer