-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathSend Pushbullet Notification.ps1
49 lines (43 loc) · 3.38 KB
/
Send Pushbullet Notification.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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#####################################################################################
#Script Created by Phillip Marshall #
#Creation Date 6/5/14 #
#Revision 2 #
#Revisions Changes - Added Commenting. #
# #
#Description - This Script will create a pushbullet notification and send to all #
#devices for a given API key. #
# #
#####################################################################################
function Send-PBNotification
{
Param
(
[Parameter(Mandatory = $False)]
[STRING]$APIKey,
[Parameter(Mandatory = $False)]
[STRING]$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 $credentials
# loop through devices and send notification
foreach ($device in $pushDevices.devices)
{
# build the notification
$notification = @{
device_iden = $device.iden
type = 'note'
title = 'Labtech Alert'
body = $message
}
# push the notification
Invoke-RestMethod -Uri 'https://api.pushbullet.com/api/pushes' -Body $notification -Method Post -Credential $credentials
}
}
$pushbulletApiKeys = @('')
$message = ""
# send the notification(s)
foreach ($apiKey in $pushbulletApiKeys) {
Send-PBNotification -APIKey $apiKey -Message $message
}