From 93f0b92f9739d8e5cecfda9a56c635384d3f875a Mon Sep 17 00:00:00 2001 From: pganglbauer <124790274+pganglbauer@users.noreply.github.com> Date: Wed, 8 Feb 2023 14:39:30 +0100 Subject: [PATCH] Update scom/opsgenie.ps1 Added support for custom resolutionstate values --- scom/opsgenie.ps1 | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/scom/opsgenie.ps1 b/scom/opsgenie.ps1 index 2221935..5783cf6 100644 --- a/scom/opsgenie.ps1 +++ b/scom/opsgenie.ps1 @@ -103,7 +103,7 @@ $params = @{ alertId = $AlertID alertName = if($alert.Name) {$alert.Name} else {"Not Present"} alertDescription = if($alert.Description) {$alert.Description} else {"Not Present"} - resolutionState = if($alert.ResolutionState -eq 0) {"New"} elseif($alert.ResolutionState -eq 255) {"Closed"} else {"Not Present"} + resolutionState = if($alert.ResolutionState -eq 0) {"New"} elseif($alert.ResolutionState -eq 255) {"Closed"} elseif($alert.ResolutionState) {$alert.ResolutionState.ToString()} else {"Not Present"} resolutionStateLastModified = if($alert.TimeResolutionStateLastModified) {$alert.TimeResolutionStateLastModified.ToString()} else {"Not Present"} priority = if($alert.Priority) {$alert.Priority.ToString()} else {"Not Present"} owner = if($alert.Owner) {$alert.Owner} else {"Not Present"} @@ -135,7 +135,7 @@ $params = @{ if ($params.resolutionstate -match "Not Present"){ - if ($enableLogging){Add-OpsgenieIntegrationLogEntry -logLevel "WARNING" -logMessage "The following SCOM alert $($alert.id) will not be sent to Opsgenie as it does not contain resolutionState `"New`" or `"Closed`"."} + if ($enableLogging){Add-OpsgenieIntegrationLogEntry -logLevel "WARNING" -logMessage "The following SCOM alert $($alert.id) will not be sent to Opsgenie as it does not contain a resolutionState."} } else { $json = ConvertTo-Json -InputObject $params @@ -150,4 +150,4 @@ else { if ($enableLogging){Add-OpsgenieIntegrationLogEntry -logLevel "ERROR" -logMessage "Opsgenie intergration script has failed to POST SCOM alert details to the Opsgenie API: Exception Type='$($_.Exception.GetType().FullName)',Exception Message='$($_.Exception.Message)'"} } } -write-output $IntegrationLogEntry | Out-File $logfile -Append \ No newline at end of file +write-output $IntegrationLogEntry | Out-File $logfile -Append