Skip to content

Instantly share code, notes, and snippets.

@volkanpaksoy
Created October 31, 2019 14:18
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 volkanpaksoy/c711c19e19799b1ba4193d79d364dc76 to your computer and use it in GitHub Desktop.
Save volkanpaksoy/c711c19e19799b1ba4193d79d364dc76 to your computer and use it in GitHub Desktop.
SendMailConsumer
. ".\send-email.ps1"
# Get the last uploaded image
$latestImage = Get-S3Object -BucketName {BUCKET} `
-AccessKey {ACCESS KEY} `
-SecretKey {SECRET KEY} `
-Key {SUBFOLDER} `
| Sort-Object LastModified -descending `
| Select -First 1
Write-Host "Last image uploaded at" $latestImage.LastModified
# Compare with current time
$currentTime = Get-Date
Write-Host "Current system time:" $currentTime
# If it's older than a day send notification
If ( ($currentTime - $latestImage.LastModified).Days -ge 1)
{
Write-Host "Something's wrong. Better bug someone about it."
$subject = "Security footage upload failure"
$body = "Better have a look. Last image uploaded at" + $latestImage.LastModified
Send-Mail $subject $body
}
else
{
Write-Host "Relax, your Pi is working just fine"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment