Created
February 4, 2016 19:21
-
-
Save strigona-worksight/a715c9035e42aaf8cad5 to your computer and use it in GitHub Desktop.
Delete pushes from a chat
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Deletes pushes from a chat with another contact | |
$targetContact = '[email protected]' | |
$batchSize = 50 | |
$accessToken = 'xxxxxxx' | |
$headers = @{'Access-Token' = $accessToken } | |
Try | |
{ | |
$pushesUrl = "https://api.pushbullet.com/v2/pushes?email=" + $targetContact + '&limit=' + $batchSize | |
$data = Invoke-RestMethod -Uri $pushesUrl -Headers $headers -ContentType 'application/json' | |
$pushes = $data[0].pushes | |
$i = 0 | |
foreach ($push in $pushes) | |
{ | |
$url = "https://api.pushbullet.com/v2/pushes/" + $push.iden | |
Try | |
{ | |
Invoke-RestMethod -Method Delete -Uri $url -Headers $headers | |
} | |
Catch | |
{ | |
$_.Exception.Message | |
Break | |
} | |
$i++ | |
$i | |
} | |
"Done" | |
} | |
Catch | |
{ | |
$_.Exception.Message | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment