-
Notifications
You must be signed in to change notification settings - Fork 0
/
PowerPushBullet.ps1
31 lines (24 loc) · 940 Bytes
/
PowerPushBullet.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#
# PowerPushBullet created by Wipsly - www.wipsly.com
#
# Function to send push notification
function sendPushNotification($title, $message) {
# API-Key
$apikey = 'YOURAPIKEY'
# Make PSCredential object from apikey
$cred = New-Object System.Management.Automation.PSCredential ($apiKey, (ConvertTo-SecureString $apikey -AsPlainText -Force))
# Get all devices
$devices = Invoke-RestMethod -Uri 'https://api.pushbullet.com/api/devices' -Method Get -Credential $cred
# Loop trough all devices and send notification
foreach ($device in $devices.devices) {
# Create the notification
$notification = @{
device_iden = $device.iden
type = 'note'
title = $title
body = $message
}
# Send the notification
Invoke-RestMethod -Uri 'https://api.pushbullet.com/api/pushes' -Body $notification -Method Post -Credential $cred
}
}