Public/Send-PushoverNotification.ps1
function Send-PushoverNotification { param ( [Parameter(Mandatory)] [ValidatePattern('[A-Za-z0-9]{30}')] [string]$ApplicationToken, [Parameter(Mandatory)] [ValidatePattern('[A-Za-z0-9]{30}')] [string]$Recipient, [ValidateLength(1, 250)] [string]$Title, [Parameter(Mandatory)] [ValidateLength(1, 1024)] [string]$Message, [switch]$Html, [ValidateLength(1, 250)] [string]$SupplementaryUrl, [ValidateLength(1, 100)] [string]$SupplementaryUrlTitle, [ValidatePattern('[A-Za-z0-9_-]{1,25}')] [string[]]$Device, [ValidateSet('pushover', 'bike', 'bugle', 'cashregister', 'classical', 'cosmic', 'falling', 'gamelan', 'incoming', 'intermission', 'magic', 'mechanical', 'pianobar', 'siren', 'spacealarm', 'tugboat', 'alien', 'climb', 'persistent', 'echo', 'updown', 'none')] [string]$Sound, [ValidateSet('Lowest', 'Low', 'Normal', 'High')] [string]$Priority = 'Normal' ) $Uri = "https://api.pushover.net/1/messages.json" $Parameters = @{ token = $ApplicationToken user = $Recipient message = $Message } if ($Title) { $Parameters.title = $Title } if ($Device) { $Parameters.device = $Device -join ',' } if ($Html) { $Parameters.html = 1 } if ($Sound) { $Parameters.sound = $Sound } if ($SupplementaryUrl) { $Parameters.url = $SupplementaryUrl if ($SupplementaryUrlTitle) { $Parameters.url_title = $SupplementaryUrlTitle } } switch ($Priority) { 'Lowest' { $Parameters.priority = -2 } 'Low' { $Parameters.priority = -1 } 'Normal' { $Parameters.priority = 0} 'High' { $Parameters.priority = 1 } default { throw "Unsupported priority '$Priority'" } } $Parameters | Invoke-RestMethod -Uri $Uri -Method Post } |