Skip to content

piouson/Resolve-Open-Alerts

Repository files navigation

Resolve Open Alerts

A Datto RMM Component to resolve Open Alerts via the RMM API.

This Component compliments existing Alert Resolution options in RMM, offering more flexibility and control over Alert Resolution, especially for 100s and 1000s of Open Alerts.

License: GPL-3 Powershell: Version 4, 5 and 6 Platforms: Windows, macOS, Linux
Releave: Version 2 Release Date Downloads Open Issues

Resolve Open Alerts sample image

Prerequisites

Deployment

Import component in RMM

Save RMM API token on target device

  • In RMM, Activate the API
  • Save the API Key, API Secret Key and API URL in a text file
  • Download RMM API example files and extract powershell_token.ps1
  • Open Powershell ISE as Administrator and open script powershell_token.ps1
  • Scroll to the bottom of powershell_token.ps1, add code below and run script

For options outside Powershell, use curl_token.bat or csharp_token.cs

# Define parameters
$params = @{
  apiUrl        = '[API URL]'
  apiKey        = '[API Key]'
  apiSecretKey  = '[API Secret Key]'
}

# Call New-AemApiAccessToken function using defined parameters 
$key = New-AemApiAccessToken @params

# Save API Token as System Variable
[Environment]::SetEnvironmentVariable('RMMAPIKey',$key,'Machine')

Requires process refresh for changes, close and reopen Powershell ISE, then run below command to confirm token saved as System variable

[Environment]::GetEnvironmentVariable('RMMAPIKey', 'Machine')

If token is not displayed, try saving again by rerunning Powershell ISE as Administrator

RMM API token is not suitable as RMM Site Variable due to its character length exceeding limit.

Run component on target device

Environment Variables

If running in production (e.g. from RMM), you only need to configure $Env:RMMAPIKey at System level, see Deployment.

Other variables required at deployment time, must be set manually in Invoke-MockComponent for local development and mock testing.

  • $Env:CS_WS_ADDRESS - preconfigured in RMM {merlot-centrastage.net | concord-centrastage.net | etc}
  • $Env:Target {site | account}, default is site of device running component
  • $Env:SiteID, set here if $Env:Target = "site"
  • $Env:Priority {All | Information | Low | Moderate | High | Critical}
  • $Env:MonitorType, use Monitor Class names
  • $Env:DeviceType {Desktop | Laptop | Server | ESXI Host | Printer | Network Device}
  • $Env:UdfNumber {1-30}, UDF must be set to "resolvealerts" in RMM, see image below

Sample UDF value

See variables in Powershell and variables in RMM.

Running Directly in Powershell

The quickest way to try out this component is by running in Powershell.

The default RMM script timeout of 1 hour should resolve max 30,000 Alerts.

Running Tests

Requires environment variables.

Unit Tests have not been written for any functions yet, but Invoke-MockComponent can be used for local development, Integration Testing and/or Stress Testing. Just uncomment invocation at bottom of file, see snippet below.

Production/Live mode

#Invoke-MockComponent
Invoke-RMMComponent

Development mode

Invoke-MockComponent
#Invoke-RMMComponent

When using Invoke-MockComponent, Alerts are never resolved. Alert Resolution is simulated by using already Resolved Alerts as mock data.

For actual Alert Resolution in local development, use Invoke-RMMComponent directly with environment variables.

Contributing

Anyone can contribute.

  • Open a new issue to request bug fixes, features or a simple question
  • Create a pull request to submit your own fixes, unit tests, features, or for typos and document updates
  • Submit test cases

License

License: GPL-3

About

Powershell Component for Datto RMM

Resources

License

Stars

Watchers

Forks

Packages

No packages published