## 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 = 'user@example.com' From = 'user@example.com' Subject = 'Evil maid detected!' Body = "Detected laptop opened at $now" SmtpServer = 'smtp@example.com' } Send-MailMessage @params } $lastAwake = $now }