Skip to content

Instantly share code, notes, and snippets.

Last active Sep 22, 2016
What would you like to do?
PowerShell function to send alert to PushAlot
function Send-PushAlot {
Send alert via to Windows Phone or Desktop device app
$pushTitle = "test",
$pushBody = "text here",
$pushLinkTitle = 'Gist GitHub Link',
$pushLink = '',
$pushURI = '',
$pushToken = 'Put your token from here'
Add-Type -AssemblyName System.Web
$message = Invoke-WebRequest -Uri $pushURI -Method POST -Body "AuthorizationToken=$($pushToken)&Title=$([System.Web.HttpUtility]::UrlEncode($pushTitle))&Body=$([System.Web.HttpUtility]::UrlEncode($pushBody))&LinkTitle=$([System.Web.HttpUtility]::UrlEncode($pushLinkTitle))&Link=$([System.Web.HttpUtility]::UrlEncode($pushLink))"
switch ($message.StatusCode)
"200" {Write-Host -ForegroundColor Green "Message Sent"}
"400" {Write-Host -ForegroundColor Red "Input data validation failed. Check result information Description field for detailed information."}
"406" {Write-Host -ForegroundColor Red "Message throttle limit hit. Check result information Description field for information which limit was exceeded."}
"410" {Write-Host -ForegroundColor Red "The AuthorizationToken is no longer valid and no more messages should be ever sent again using that token. "}
"500" {Write-Host -ForegroundColor Red "Something is broken"}
"510" {Write-Host -ForegroundColor Red "servers are currently overloaded with requests"}
catch [System.Net.WebException]
Write-Host -ForegroundColor Red $_.Exception.Message
Copy link

shareonline commented Sep 22, 2016

Nice! Thanks 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment