
So I made this powershell script for my son (4) who didn't fall far from the tree and seems to really enjoy computer games. There have been issues getting him to turn off the games and head to bed lately, so I devised the following script:$now = Get-Date -Format "HH:mm" $then = "18:55" $dur = New-TimeSpan -Start $now -End $then $sec = $dur.TotalSeconds For ($i=$sec; $i -gt 1; $i–-) { Write-Progress -Activity "Time till bedtime" -SecondsRemaining $i -PercentComplete ((($sec-$i)/$sec) *100) Start-Sleep 1 } Add-Type -AssemblyName System.speech $speak = New-Object System.Speech.Synthesis.SpeechSynthesizer $speak.Speak("Son's name, You have 5 minutes left") sleep 300 $speak.Speak("Son's name, It's bedtime. Turn off the switch, and go upstairs please") For ($i=1050; $i -gt 50; $i-=25) { [console]::beep($i,300) sleep 0.5 } For ($i=100; $i -gt 1; $i-=1) { [console]::beep(400,300) [console]::beep(400,300) sleep 1 $speak.Speak("Son's name, time for bed"); sleep 3 } # optional, if he's actually playing on the computer stop-computer It has been working really well the past few nights, and he thinks it's really funny to have the computer talk to him via /r/Parenting https://ift.tt/2Lolm9c
No comments:
Post a Comment