Skip to content

@scichelli /sleep.ps1
Created

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Show an alert and then set the computer to sleep
$WarningDuration = 5
$MessagePlural = ""
if ($WarningDuration -gt 1) { $MessagePlural = "s" }
[System.Media.SystemSounds]::Asterisk.play()
[void] [Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms")
[windows.forms.messagebox]::show(("Save your work. Sleep in {0} minute{1}." -f $WarningDuration, $MessagePlural))
Start-Sleep -Second ($WarningDuration * 60)
[System.Media.SystemSounds]::Beep.play()
Start-Sleep -Second 2
[System.Windows.Forms.Application]::SetSuspendState("Suspend", $false, $true)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.