Celerium.RocketCyber
Celerium.RocketCyber

CI GitHub_Pages

PoshGallery_Version PoshGallery_Platforms PoshGallery_Downloads codeSize

Contributors Forks Stargazers Issues

GitHub_License


Logo

PowerShell Gallery · Report Bug · Request Feature


Buy me a coffee

Whether you use this project, have learned something from it, or just like it, please consider supporting it by buying me a coffee, so I can dedicate more time on open-source projects like this :)

Buy Me A Coffee

About The Project

The Celerium.RocketCyber PowerShell wrapper offers a way to read data from the RocketCyber (Kaseya managed SOC) Customer REST API (v3) and use it in third-party reporting tools. This module serves to abstract away the details of interacting with RocketCyber’s API endpoints in such a way that is consistent with PowerShell nomenclature. This gives system administrators and PowerShell developers a convenient and familiar way of using RocketCyber’s API to create documentation scripts, automation, and integrations.

RocketCyber does not publish an OpenAPI spec, so the functions are written by hand from the API documentation. Every endpoint is tracked in the endpoints.csv file.

The RocketCyber API is read-only, every endpoint uses the GET method. In order to maintain PowerShell best practices, only approved verbs are used and PowerShell’s verb-noun nomenclature is respected. Each noun is prefixed with RocketCyber in an attempt to prevent naming problems.

  • GET -> Get-RocketCyber*

For example, one might access the /v3/agents endpoint by running the following PowerShell command:

Get-RocketCyberAgent -AccountId 12345
  • Some functions cover more than one endpoint with parameter sets. Get-RocketCyberEvent -AppId 7 gets events & Get-RocketCyberEvent -EventSummary gets the event summary
  • The full API response is returned, paged endpoints return an object with the totalCount, currentPage, totalPages, dataCount, & data properties
  • Paged endpoints have -Page & -PageSize parameters and an -AllResults switch that requests every page for you
  • Parameters that accept multiple values (such as -AccountId 1, 2) are sent as repeated query parameters (accountId=1&accountId=2)

(back to top)

Install

This module can be installed directly from the PowerShell Gallery with the following command:

Install-Module -Name Celerium.RocketCyber
  • :information_source: This module supports Windows PowerShell 5.1 and PowerShell 7+ on Windows, Linux, & macOS. Every change is tested on all of them by the CI workflow.
  • :information_source: If PowerShellGet is unavailable, you can manually download the main branch and place the latest version of Celerium.RocketCyber from the build folder into the (default) C:\Program Files\WindowsPowerShell\Modules folder.

Celerium.RocketCyber project documentation can be found on Github Pages

  • A full list of functions can be retrieved by running Get-Command -Module Celerium.RocketCyber.
  • Help info and a list of parameters can be found by running Get-Help <command name>, such as:
Get-Help Get-RocketCyberAgent
Get-Help Get-RocketCyberAgent -Full

(back to top)

Initial Setup

After installing this module, you will need to configure both the base URI & API key that are used to talk with the RocketCyber API.

  1. Run Add-RocketCyberBaseURI
    • By default, RocketCyber’s https://api-us.rocketcyber.com uri is used. Use Add-RocketCyberBaseURI -DataCenter EU for https://api-eu.rocketcyber.com
    • If you have your own API gateway or proxy, you can use Add-RocketCyberBaseURI -BaseURI https://myapi.gateway.example.org, only https is supported
    • The API version (/v3) is added by each function, so it is not part of the base uri
  2. Run Add-RocketCyberAPIKey -ApiKey '12345'
    • It will prompt you to enter your API key as a secure string if you do not specify it
    • RocketCyber API keys are generated in the RocketCyber portal under Provider Settings > RocketCyber API
  3. [optional] Run Test-RocketCyberAPIKey
    • Makes a single GET request to the /v3/account endpoint to validate the base uri & API key
  4. [optional] Run Export-RocketCyberModuleSettings
    • This will create a config file at %UserProfile%\Celerium.RocketCyber that holds the base uri & API key information.
    • Next time you run Import-Module -Name Celerium.RocketCyber, this configuration file will automatically be loaded.
    • :warning: Exporting module settings encrypts your API key in a format that can only be unencrypted by the user principal that encrypted the secret. It makes use of .NET DPAPI, which for Windows uses reversible encrypted tied to your user principal. This means that you cannot copy your configuration file to another computer or user account and expect it to work.
    • :warning: However in Linux\Unix operating systems the secret keys are more obfuscated than encrypted so it is recommend to use environment variables or a more secure & cross-platform storage method.

Environment variables (recommended for CI\CD, Linux, & macOS) are loaded when the module is imported and take precedence over the configuration file:

$env:ROCKETCYBER_BASE_URI   = 'https://api-us.rocketcyber.com'   # Optional
$env:ROCKETCYBER_API_KEY    = 'your-api-key'
Import-Module -Name Celerium.RocketCyber

(back to top)

Usage

Calling an API endpoint is as simple as running its Get-RocketCyber* function.

# Get the accounts the API key can access, including the details of each sub-account
Get-RocketCyberAccount -Details

# Get the first 1000 agents of an account, or every agent
Get-RocketCyberAgent -AccountId 12345
(Get-RocketCyberAgent -AccountId 12345 -AllResults).data

# Get the offline agents created in a date range
Get-RocketCyberAgent -Connectivity offline -StartDate '2025-01-01' -EndDate '2025-02-01'

# Get the apps & the suspicious events of an app
Get-RocketCyberApp -Status active
Get-RocketCyberEvent -AppId 7 -Verdict suspicious -Sort dates:desc -PageSize 50

# Get every open incident & the active suppression rules
(Get-RocketCyberIncident -Status open -AllResults).data
Get-RocketCyberSuppressionRule -Status active
Get-RocketCyberSuppressionRule -ID 100 -UserId 563   # the single rule endpoint requires a user ID

# Get a report export of the incidents as CSV (the report is created for a RocketCyber user)
Get-RocketCyberReport -UserId 563 -FileType csv -ItemType incidents | Set-Content -Path ./Incidents.csv
  • The full list of endpoints & their functions is tracked in the endpoints.csv file and on Github Pages.
  • Example scripts can be found in the examples folder of this repository. They only use read-only requests.

Supported functions

The module has 10 public functions in 10 categories that cover all 12 endpoints in the v3 API documentation. Every function is a read-only Get- function.

Category EndpointUri Method Function
Account /v3/account GET Get-RocketCyberAccount
Agents /v3/agents GET Get-RocketCyberAgent
Apps /v3/apps GET Get-RocketCyberApp
Defender /v3/defender GET Get-RocketCyberDefender
Events /v3/events GET Get-RocketCyberEvent
Events /v3/events/summary GET Get-RocketCyberEvent (IndexByEventSummary)
Firewalls /v3/firewalls GET Get-RocketCyberFirewall
Incidents /v3/incidents GET Get-RocketCyberIncident
Office /v3/office GET Get-RocketCyberOffice
Suppression /v3/suppression/rules GET Get-RocketCyberSuppressionRule
Suppression /v3/suppression/rule/{ruleId} GET Get-RocketCyberSuppressionRule (ById)
Reports /v3/reportApi GET Get-RocketCyberReport

Upgrading from 1.x

Version 2.0.0 aligns the module with the other Celerium modules & fixes several bugs, which changes some behavior:

  • -AllResults now returns every page, version 1.x requested the first page again for every page
  • Errors are now terminating errors (throw) instead of non-terminating errors that returned nothing. Requests that are rate limited (429) or fail with a 502, 503, or 504 status code are retried up to 3 times
  • The base uri is now https://api-us.rocketcyber.com (the /v3 path is part of each endpoint), a saved or custom base uri that ends with /v3 still works because only the scheme & host are kept. Only https base uris are accepted
  • Get-RocketCyberBaseURI returns the base uri without the /v3 path
  • Switches such as -Details are sent as true`false instead of True\False`
  • An -AllResults request without results returns an object with an empty data property instead of $null
  • ConvertTo-RocketCyberQueryString returns the query string instead of a UriBuilder & no longer has a -ResourceUri parameter
  • The internal functions use the Celerium names Add-RocketCyberAPIKey, Add-RocketCyberBaseURI, etc. PowerShell command names are not case-sensitive, so existing scripts keep working. All 1.x aliases (such as Get-RCAgent & Set-RocketCyberBaseURI) are kept
  • Get-RocketCyberModuleSettings -OpenConfFile is now -OpenConfigFile (-OpenConfFile still works as an alias). The Get-RCModuleSettings alias now points to Get-RocketCyberModuleSettings (1.x used the Export-RCModuleSettings alias by mistake)
  • Export-RocketCyberModuleSettings throws an error instead of closing the PowerShell session when the base uri or API key is not set
  • New: Get-RocketCyberSuppressionRule, Get-RocketCyberReport (CSV/JSON report exports, needs a RocketCyber user ID & optionally the console report key as -SourceKey), the -Config switch, Get-RocketCyberApp -Sort -Order, Get-RocketCyberEvent -UserId -DeviceId, Get-RocketCyberIncident -PublishedAt -Order & the suppressed status. -Sort accepts multiple values

Development

The module is built from the files in this repository with the scripts in the build folder. The same steps are run by the GitHub Actions workflows in .github/workflows.

Script Description
Install-Prerequisites.ps1 Installs the latest ModuleBuilder, Pester, Microsoft.PowerShell.PlatyPS, & PSScriptAnalyzer
Invoke-ModuleBuild.ps1 Builds the module into build/Celerium.RocketCyber/<version>
Invoke-PesterTests.ps1 Runs the Pester tests against the source or built module
Invoke-HelpContent.ps1 Regenerates the GitHub pages documentation in docs with Microsoft.PowerShell.PlatyPS
Publish-CeleriumModule.ps1 Publishes the built module to the PowerShell Gallery
./build/Install-Prerequisites.ps1
./build/Invoke-ModuleBuild.ps1 -Version 2.0.0
./build/Invoke-PesterTests.ps1 -Version 2.0.0 -BuildTarget built

RocketCyber does not publish an OpenAPI spec, so there are no spec download or compare scripts. When a new endpoint or query parameter is added to the API documentation, add it to the function & to the Query: list in the Notes column of docs/endpoints.csv, which the Pester tests use to verify every function.

Live tests make real, read-only GET requests. They are excluded unless the following environment variable is set and the Live tag is included:

$env:ROCKETCYBER_API_KEY = 'your-api-key'
$env:ROCKETCYBER_USER_ID = '12345'   # Optional, enables the Get-RocketCyberReport test
./build/Invoke-PesterTests.ps1 -Version 2.0.0 -IncludeTag Live -ExcludeTag Online

(back to top)


Contributing

Contributions are what makes the open-source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.

If you have a suggestion that would make this better, please fork the repo and create a pull request. You can also simply open an issue with the tag “enhancement”. Don’t forget to give the project a star! Thanks again!

See the CONTRIBUTING guide for more information about contributing.

(back to top)

License

Distributed under the MIT license. See LICENSE for more information.

GitHub_License

(back to top)


Table of contents