SHOW:
|
|
- or go back to the newest paste.
| 1 | ## 1. Start this script running in PowerShell | |
| 2 | ## 2. Close your laptop lid. The next time the lid opens, the script will send a mail. | |
| 3 | ||
| 4 | $lastAwake = Get-Date; while($true) {
| |
| 5 | Start-Sleep -Seconds 1 | |
| 6 | $now = Get-Date | |
| 7 | if(($now - $lastAwake).TotalSeconds -gt 3) {
| |
| 8 | $params = @{
| |
| 9 | To = '[email protected]' | |
| 10 | From = '[email protected]' | |
| 11 | Subject = 'Evil maid detected!' | |
| 12 | Body = "Detected laptop opened at $now" | |
| 13 | SmtpServer = '[email protected]' | |
| 14 | } | |
| 15 | Send-MailMessage @params | |
| 16 | } | |
| 17 | $lastAwake = $now | |
| 18 | } |