Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update scom/opsgenie.ps1 #85

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions scom/opsgenie.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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"}
Expand Down Expand Up @@ -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
Expand All @@ -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
write-output $IntegrationLogEntry | Out-File $logfile -Append