-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathpushbullet.ps1
70 lines (54 loc) · 2.03 KB
/
pushbullet.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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
<#
.SYNOPSIS
This script sends push notifications via the PushBullet API
.DESCRIPTION
This function can be used to send push notifications. This script will likely grow to do more functions via the Pushbullet API.
You must have a Pushbullet API key in order for this function to work. The link to create an access token is the following
https://www.pushbullet.com/#settings/account
.PARAMETER APIKey
This parameter is required in order to connect to the Pushbullet API.
.PARAMETER Message
The message you wish to send to the PushBullet device
.PARAMETER Device
Specifiy which device you'd like to send to by using the device_iden string. If this isnt specified the push gets sent to all devices.
.PARAMETER Url
PushBullet API URL. This parameter is set to https://api.pushbullet.com/v2/pushes
.EXAMPLE
Send-PushBulletMessage -APIKey "*****" -Message "Str8 from PowerShell"
.NOTES
General notes
#>
Function Send-PushBulletMessage {
param(
[Parameter(Mandatory=$true)]$APIKey,
[Parameter(Mandatory=$true)]$Message,
[Parameter(Mandatory=$false)]$Device,
[Parameter(Mandatory=$false)]$Url = "https://api.pushbullet.com/v2/pushes"
)
$Body = @{
type = "note"
title = $Message
device_iden = $Device
}
$result = Invoke-WebRequest -Uri $URL -Method Post -Body $Body -Headers @{"Access-Token" = $APIKey}
if($result.StatusCode -eq '200'){
Write-Output "Message Sucessfully Sent"
}
}
#Send-PushBulletMessage -APIKey "" -Message "test" -Device ""
Function Get-PushBulletDevices {
param(
[Parameter(Mandatory=$true)]$APIKey,
[Parameter(Mandatory=$false)]$Url = "https://api.pushbullet.com/v2/devices"
)
(Invoke-RestMethod -Uri $URL -Method Get -Headers @{"Access-Token" = $APIKey}).devices
}
#Get-PushBulletDevices -APIKey ""
Function Get-WhoAmI {
param(
[Parameter(Mandatory=$true)]$APIKey,
[Parameter(Mandatory=$false)]$Url = "https://api.pushbullet.com/v2/users/me"
)
Invoke-RestMethod -Uri $URL -Method Get -Headers @{"Access-Token" = $APIKey}
}
#Get-WhoAmI -APIKey ""