Powershell – Send PushBullet Notifications from PRTG
Powershell v3+ script to send notifications using the Pushbullet notification service. The script will determine all available devices based on the provided API keys and send the notification to all of them. Adding multiple API keys will result in the notification being sent to those users as well.
# specify the pushbullet api key(s) $pushbulletApiKeys = @('xxxxxxxxxxxxxxxxxxxxxxxxx') # build the message from the arguments passed by PRTG for ($i=0; $i -lt $args.count; $i++) { $message+="$($args[$i]) " } # function to pushbullet notifications function sendPushBulletNotification($apiKey, $message) { # convert api key into PSCredential object $credentials = New-Object System.Management.Automation.PSCredential ($apiKey, (ConvertTo-SecureString $apiKey -AsPlainText -Force)) # get list of registered devices $pushDevices = Invoke-RestMethod -Uri 'https://api.pushbullet.com/api/devices' -Method Get -Credential $cred # loop through devices and send notification foreach ($device in $pushDevices.devices) { # build the notification $notification = @{ device_iden = $device.iden type = 'note' title = 'PRTG Alert' body = $message } # push the notification Invoke-RestMethod -Uri 'https://api.pushbullet.com/api/pushes' -Body $notification -Method Post -Credential $credentials } } # send the notification(s) foreach ($apiKey in $pushbulletApiKeys) { sendPushBulletNotification $apiKey $message }