Skip to content

Instantly share code, notes, and snippets.

@Icaruk
Last active March 2, 2022 09:35
Show Gist options
  • Save Icaruk/132f2076165c22ac1e58180a690e5d58 to your computer and use it in GitHub Desktop.
Save Icaruk/132f2076165c22ac1e58180a690e5d58 to your computer and use it in GitHub Desktop.
Write-Host "Shutdown timer..."
$Horas = Read-Host -Prompt 'Hours (can be 0)'
$Minutos = Read-Host -Prompt 'Minutes'
$Segundos = 0
if ($Horas -eq 0) {
$Horas = 0
}
if ($Minutos -eq 0) {
$Minutos = 0
$Segundos = 5
}
$Segundos += [int]$Horas * 60 * 60
$Segundos += [int]$Minutos * 60
$Fecha = (Get-Date).AddSeconds($Segundos)
$FechaStr = $Fecha.ToString('HH:mm dd/MM/yyyy')
Write-Host ""
Write-Host -ForegroundColor red "Shutdown will be at $FechaStr"
Write-Host -ForegroundColor green Press CTRL+C to cancel.
Timeout /T $Segundos /nobreak
# Start-Sleep -Seconds $Segundos
Write-Host "Shutting down..."
Stop-Computer
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment