## 1. Start this script running in PowerShell
## 2. Close your laptop lid. The next time the lid opens, the script will send a mail.
$lastAwake = Get-Date; while($true) {
Start-Sleep -Seconds 1
$now = Get-Date
if(($now - $lastAwake).TotalSeconds -gt 3) {
$params = @{
To = '[email protected]'
From = '[email protected]'
Subject = 'Evil maid detected!'
Body = "Detected laptop opened at $now"
SmtpServer = '[email protected]'
}
Send-MailMessage @params
}
$lastAwake = $now
}
Comments