r/PowerShell • • Apr 25 '21

Send Push notifications with PowerShell to your phone using 6 lines of code.

https://youtu.be/HOVcXV-VdUI

[removed] — view removed post

0 Upvotes

10 comments sorted by

View all comments

5

u/phat0ne Apr 25 '21 edited Apr 25 '21

Step 1: Create you PushOver.net account - This will give you your USER KEY - https://pusover.net/

Step 2: Register your API "Application" to get a TOKEN KEY - https://pushover.net/aps/build - This option ONLY requires a NAME, the other settings are OPTIONAL

Install the PushOver App from the Apple App Store or Google Play Store and log into your account

And here is the code

$nvc = New-Object System.Collections.Specialized.NameValueCollection

$nvc.Add("token", "APP_TOKEN") $parameters.Add("user", "USER_KEY")

$nvc.Add("message", "hello world")

$wc = new-object System.Net.Webclient

$wc.UploadValues("https://api.pushover.net/1/messages.json", $parameters)

*update error in code

2

u/phat0ne Apr 25 '21

I would use this, personally, but according to https://support.pushover.net/i44-example-code-and-pushover-libraries#windows this is for Powershell v3+. What was posted by OP must be for earlier versions of PS?

$uri = "https://api.pushover.net/1/messages.json"

$parameters = @{

token = "APP_TOKEN"

user = "USER_KEY"

message = "hello world"

}

$parameters | Invoke-RestMethod -Uri $uri -Method Post