Skip to content

Instantly share code, notes, and snippets.

@ecspresso
Created November 22, 2019 10:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ecspresso/9f8282d9456fb7fb2e3fd894d0e51cca to your computer and use it in GitHub Desktop.
Save ecspresso/9f8282d9456fb7fb2e3fd894d0e51cca to your computer and use it in GitHub Desktop.
Get updates from Dr Scripto via PushBullet
$path = "$PSScriptRoot\drscripto_LastSeen.txt"
$apikey = '' # Secure String
if(-not (Test-Path -Path $path)) {
$null | Out-File $path
}
$latest = Get-Content $path
$rss = Invoke-RestMethod -Uri 'https://blogs.technet.microsoft.com/heyscriptingguy/feed/' | Select-Object -First 1
if($rss.title -ne $latest) {
$headers = @{
'Access-Token' = [PSCredential]::new('null', ($apikey | ConvertTo-SecureString)).GetNetworkCredential().Password
}
$uri = 'https://api.pushbullet.com/v2/pushes'
$data = @{
type = 'note'
title = 'Update from Doctor Scripto!'
body = '{0}{1}{2}{1}Published: {3}' -f $rss.title, [System.Environment]::NewLine, $rss.link, [DateTime]$rss.pubDate
guid = (New-Guid).Guid
}
$data = $data | ConvertTo-Json -Depth 100
[void] (Invoke-RestMethod -Uri $uri -Headers $headers -ContentType 'application/json' -Method POST -Body $data)
$rss.title | Out-File $path
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment