Receive Real-Time Veeam Backup Notifications in Telegram Using PowerShell

VEEAM BACKUP

ITQuickFix

4/19/20252 min read

In this article, I’ll show you how to integrate Veeam Backup with Telegram to get real-time notifications directly to your phone or desktop whenever a backup job starts or finishes — whether successful, failed, or with warnings.

We’ll use a Telegram bot, a PowerShell script, and the Windows Event Log entries created by Veeam to send alerts automatically.

Step 1 – Create a Telegram Bot
  1. Open a chat with @BotFather and send /start.

  2. Send /newbot and follow the prompts to assign it a name and username.

  3. You’ll receive a bot token — save this; you’ll need it in your script.

Step 2 – Get the Group Chat ID
  1. Create a new Telegram group (e.g., ITQuickFixDemo).

  2. Add your bot to the group.

  3. Add @getidsbot to the group — it will display the chat ID automatically.

  4. Remove @getidsbot from the group.

Step 3 – PowerShell Script
Function Send-Telegram {

Param([Parameter(Mandatory = $true)][String]$Message)

$Telegramtoken = "YOUR_BOT_TOKEN"

$Telegramchatid = "YOUR_GROUP_CHAT_ID"

[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12

$Response = Invoke-RestMethod -Uri "https://api.telegram.org/bot$($Telegramtoken)/sendMessage" -Method POST -Body @{

chat_id = $Telegramchatid

text = $Message

parse_mode = "HTML"

}

}

# Custom string

$CustomString = "Backup Control:"

# Global variable to keep track of the last sent event time

if (-not $Global:LastEventTime) {

$Global:LastEventTime = [datetime]::MinValue

}

# Function to check if the event is within the 30-second threshold

Function IsRecentEvent {

Param($EventTime)

$TimeDifference = (Get-Date) - $EventTime

return $TimeDifference.TotalSeconds -le 30

}

# Capture the event of backup starting (ID 1)

$StartEvent = Get-WinEvent -MaxEvents 1 -FilterHashTable @{ Logname = "Veeam Backup"; ID = 1 }

if ($StartEvent) {

$Message = $StartEvent.Message

$EventTime = $StartEvent.TimeCreated

$FormattedEventDate = $EventTime.ToString("dd-MM-yyyy")

# Check if the event date is equal to the current date and if it is recent

if (($FormattedEventDate -eq (Get-Date).ToString("dd-MM-yyyy")) -and (IsRecentEvent $EventTime)) {

$EventTimeString = "Event Time: $($EventTime.ToString("dd-MM-yyyy HH:mm:ss"))"

$MessageToSend = "⚙ " + $CustomString + " Backup Started" + "rn" + $EventTimeString + "rn" + $Message

# Update the last event time to the current event time

$Global:LastEventTime = $EventTime

Send-Telegram $MessageToSend

}

}

# Capture the event of backup finishing (IDs 190 and 191)

$FinishEvent = Get-WinEvent -MaxEvents 1 -FilterHashTable @{ Logname = "Veeam Backup"; ID = 190, 191 }

if ($FinishEvent) {

$Message = $FinishEvent.Message

$EventTime = $FinishEvent.TimeCreated

$FormattedEventDate = $EventTime.ToString("dd-MM-yyyy")

# Check if the event message contains "Success", "Failed", or "Warning"

if ($Message -match "finished with Success") {

$CustomString = "✅ " + $CustomString # Green circle emoji

} elseif ($Message -match "finished with Failed") {

$CustomString = "❌ " + $CustomString # Red circle emoji

} elseif ($Message -match "finished with Warning") {

$CustomString = "⚠ " + $CustomString # Orange circle emoji

}

# Check if the event date is equal to the current date and if it is recent

if (($FormattedEventDate -eq (Get-Date).ToString("dd-MM-yyyy")) -and (IsRecentEvent $EventTime)) {

$EventTimeString = "Event Time: $($EventTime.ToString("dd-MM-yyyy HH:mm:ss"))"

# Update the last event time to the current event time

$Global:LastEventTime = $EventTime

# Concatenate custom string, event time, and message

$MessageToSend = $CustomString + "rn" + $EventTimeString + "rn" + $Message

# Send the message via Telegram

Send-Telegram $MessageToSend

}

}

Step 4 – Schedule the Script

Instead of running the script every few minutes, you can configure Task Scheduler to execute it only when a specific Veeam event occurs. This is more efficient and accurate.

  1. Open Task Scheduler.

  2. Create a new task and go to the Triggers tab.

  3. Choose “Begin the task: On an event”.

  4. Configure as shown:

    • Log: Veeam Agent

    • Source: Veeam Agent

    • Event ID: Blank

  5. Under Actions, set:

    • Program/script: powershell.exe

    • Arguments: -ExecutionPolicy Bypass -File "C:\Path\To\Script.ps1"

Conclusion

This way, the script only runs when Veeam writes a relevant event to the Windows Event Log.

This integration helps you get notified immediately whenever a Veeam Backup job runs. You can monitor your environment in real time without relying on email or manually opening the console.

It’s lightweight, customizable, and very easy to implement. A perfect solution for system administrators or backup operators who want alerts that actually matter.