Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Multi-Line Push Bullet Notification from PowerShell. Associated blogpost https://blog.darrenjrobinson.com/accessing-your-ubiquiti-unifi-network-configuration-with-powershell/
# My Push Bullet Access Token
# Created via Profile Page https://www.pushbullet.com/#settings/account
$pbAccessToken = 'yourPushBulletAccessToken'
# Push Bullet API URI
$pbApiURI = "https://api.pushbullet.com/"
# Web Request Header
$pbHeader = @{"Access-Token" = $pbAccessToken
'Content-Type' = "application/json"
}
# Format for Push Notification
$pbBodyStatus = $null
foreach ($user in $uClientStatus) {
if ($user.homeSince) {
$pbBodyStatus += "$($user.hostname) $($user.status) \nLast Seen: $($user.lastHome) \nHome Since: $($user.homeSince) \n\n"
}
else {
$pbBodyStatus += "$($user.hostname) $($user.status) \nLast Seen: $($user.lastHome) \n\n"
}
}
$pbBody = @{"type" = "note"
"title" = "Who's Home and Away"
"body" = $pbBodyStatus
}
# Send Push Bullet Notification
try {
$pbNotification = Invoke-RestMethod -Method Post -Headers $pbHeader -Uri ($pbApiURI + "v2/pushes") -Body ($pbBody | convertto-json).Replace('\\n', '\n')
if ($pbNotification.active = $true) {
write-host -ForegroundColor Green "Push Bullet Notification successfully sent"
}
}
catch {
write-host -ForegroundColor Red "Push Bullet Notification Failed to Send"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.