A PowerShell module for centralized error logging from NinjaRMM scripts to Azure Log Analytics.
RMMLogging provides a simple, secure way to send error logs from NinjaRMM client scripts to Azure Log Analytics for centralized monitoring and alerting. Errors are authenticated using HMAC-SHA256 signatures to prevent unauthorized log submissions.
- ✅ Simple Integration - Single function call to log errors
- 🔒 Secure - HMAC-SHA256 signature validation
- 📊 Centralized - All errors in one Azure Log Analytics workspace
- 🔔 Alerting Ready - Query and alert on errors in Azure
- 🚀 Lightweight - Minimal overhead, fails silently if logging unavailable
- 📦 Easy Installation - One-line installer from GitHub
┌─────────────────────┐
│ Client Machine │
│ (NinjaRMM Agent) │
└──────────┬──────────┘
│
│ Error + HMAC Signature
│
▼
┌─────────────────────┐
│ Azure Function │
│ │
│ 1. Validate │
│ Signature │
│ │
│ 2. Enrich with │
│ Client Data │
│ │
│ 3. Forward to │
│ Log Analytics │
└──────────┬──────────┘
│
▼
┌─────────────────────┐
│ Azure Log Analytics │
│ │
│ • Monitor errors │
│ • Create alerts │
│ • Generate reports │
└─────────────────────┘
Run this in an elevated PowerShell window:
iex ((New-Object Net.WebClient).DownloadString('https://raw.githubusercontent.com/Merit-IT/RMMLoggingModule/main/Install-RMMLogging.ps1'))- Download
RMMLogging.psm1andRMMLogging.psd1 - Copy to
C:\Program Files\WindowsPowerShell\Modules\RMMLogging\1.0.x\ - Import the module:
Import-Module RMMLogging -Force
Get-Module RMMLogging -ListAvailable
Get-Command -Module RMMLogging- Set Custom Field - Create a custom organization field called
loggingSecret - Generate Secret - Use a strong random string (recommended: 32+ characters)
# Generate a secure random secret -join ((48..57) + (65..90) + (97..122) | Get-Random -Count 32 | ForEach-Object {[char]$_})
- Store Secret - Save the secret in the
loggingSecretcustom field for each organization
Import-Module RMMLogging -Force
try {
# Your script logic
Invoke-SomeCommand
} catch {
Send-RMMError -ScriptName "MyScript" -ErrorMessage $_
throw
}Sends error information to Azure Log Analytics via Azure Function.
| Parameter | Type | Required | Description |
|---|---|---|---|
ScriptName |
String | Yes | Name of the script that encountered the error |
ErrorMessage |
String | Yes | Error message or exception details |
- ✅ Use strong random strings for
loggingSecret(32+ characters) - ✅ Rotate secrets periodically
- ✅ Use HTTPS for all communications
- ✅ Review Log Analytics queries regularly
- ✅ Set up alerts for unusual error patterns
# Check if module is installed
Get-Module RMMLogging -ListAvailable
# If not found, reinstall
iex ((New-Object Net.WebClient).DownloadString('https://raw.githubusercontent.com/Merit-IT/RMMLoggingModule/main/Install-RMMLogging.ps1'))By design, Send-RMMError fails silently to prevent logging errors from breaking your scripts:
Send-RMMError -ScriptName "Test" -ErrorMessage "Test error"The installer automatically checks for newer versions. To update:
# Run installer again
iex ((New-Object Net.WebClient).DownloadString('https://raw.githubusercontent.com/Merit-IT/RMMLoggingModule/main/Install-RMMLogging.ps1'))Or manually:
# Remove old version
Remove-Module RMMLogging -ErrorAction SilentlyContinue
Remove-Item "C:\Program Files\WindowsPowerShell\Modules\RMMLogging" -Recurse -Force
# Reinstall
# ... run installer ...