This project automates the daily download of PRTG sensors graphs and sends them to Telegram using the PRTG API and a PowerShell script.
It is designed to run unattended via Windows Task Scheduler on a PRTG server.
- Uses PRTG API Token (no username/password)
- Downloads last 24h sensor graphs
- Generates readable captions from filenames
- Sends graphs to Telegram
- Fully compatible with Windows Task Scheduler
- Safe for non-interactive execution
- Windows Server with PRTG Network Monitor
- PowerShell 5.1+
- Telegram Bot Token & Chat ID
- PRTG API Token
This project sends graphs to Telegram using a bot.
Follow the full setup guide: docs/telegram-bot-setup.md
Using an API token is recommended over username/password authentication.
- More secure
- No password rotation issues
- Works reliably with automation
- Least-privilege friendly
Follow the full setup guide: docs/prtg-api-token.md
Edit the following variables inside: scripts/GraphAutomation.ps1
# PRTG
$BaseURL = "https://example.com"
$ApiToken = $env:PRTG_API_TOKEN
# Telegram
$BotToken = $env:TELEGRAM_BOT_TOKEN
$ChatID = $env:TELEGRAM_CHAT_IDThe script is designed to run via Task Scheduler.
Program
C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe
Arguments
-ExecutionPolicy Bypass -NonInteractive -File "C:\Program Files (x86)\PRTG Network Monitor\notifications\exe\GraphAutomation.ps1"
Start in (IMPORTANT)
C:\Program Files (x86)\PRTG Network Monitor\notifications\exe
| Setting | Value |
|---|---|
| Run whether user is logged on or not | β |
| Do not store password | β UNCHECKED |
| Run with highest privileges | β |
| User account | Administrator / Service Account |
π Do NOT check βDo not store passwordβ This will cause PowerShell, API calls, and Telegram sending to fail silently.
Follow the full setup guide: docs/task-scheduler.md
π Environment Variables (IMPORTANT) Before running the script, set these once on the PRTG server. Run Powershell as Administrator.
setx PRTG_API_TOKEN "insert your PRTG_API_TOKEN" /M
setx TELEGRAM_BOT_TOKEN "insert your TELEGRAM_BOT_TOKEN" /M
setx TELEGRAM_CHAT_ID "insert your TELEGRAM_CHAT_ID" /MClose powershell (MUST) if not the script will fail.
Open a new Powershell and run the script.
.\GraphAutomation.ps1Then test from Task Scheduler:
Right click on the created task β Run
Expected result:
- Exit code: 0x0
- Telegram message received
- Use a dedicated service account for scheduled tasks
- Restrict API token permissions
- Rotate Telegram bot tokens periodically
- Enable Task Scheduler history for debugging