Generate alert via PowerShell script
M
Written by Mikel Wellsmore
Updated over a week ago

PowerShell can be used to generate native Gorelo Alerts. In this article, we will walk through generating an alert using GoreloAction -Alert via a PowerShell script.

There are currently four things that can be configured on the Alert:

Alert Severity:

-Severity 1 = Critical

-Severity 2 = Error

-Severity 3 = Warning

Alert Name:

-Name "Alert Name" = An alert with the name 'Alert Name'

Alert Description:

-Description "Alert Description" = An alert with the description 'Alert Description'

Alert Suppression:

-Suppress 4 = suppress for 4 hours (number can be changed)

-Suppress 0 = do not supress (generate an alert each time the script runs)

Example 1

GoreloAction -Alert -Severity 1 -Name "Name" -Description "Description" -Suppress 0

This would result in the following alert:

Example 2

$DriveLetter = 'C'
$DriveInfo = Get-Volume $DriveLetter
$PcUsed = 100 - ($DriveInfo.SizeRemaining * 100.0 / $DriveInfo.Size)
if ($PcUsed -gt 50.0)
{
$Severity = 3 # Warning
if ($PcUsed -gt 75.0)
{
$Severity = 1 # Critical
}
$AlertDescription= $DriveLetter + " drive usage is " + $PcUsed + " %"
GoreloAction -alert -Severity $Severity -Name "Disk Usage" -Description $AlertDescription -Suppress 0
}

NOTE! If -Suppress is not included it will default to 4 hours

Did this answer your question?