Created
November 22, 2019 10:44
-
-
Save ecspresso/9f8282d9456fb7fb2e3fd894d0e51cca to your computer and use it in GitHub Desktop.
Get updates from Dr Scripto via PushBullet
This file contains 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
$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