This commit is contained in:
Alexandre MOTTIER 2022-04-08 21:42:12 +02:00
parent f39d8e9063
commit 80950b9ff5
No known key found for this signature in database
GPG Key ID: 1BA6A0738AD40344
2 changed files with 16 additions and 0 deletions

BIN
ScheduleShutdown.exe Normal file

Binary file not shown.

16
ScheduleShutdown.ps1 Normal file
View File

@ -0,0 +1,16 @@
$RebootTime = Read-Host "Indiquez la date et heure de redémarrage au format JJ/MM/AAAA HH:MM"
$Seconds = (New-TimeSpan -Start $(Get-Date -UFormat "%d/%m/%Y %R") -End "$RebootTime").TotalSeconds
shutdown /s /f /t $Seconds | Out-Null
if ($Seconds -lt 0) {
$Error.Count = 1
}
if($Error.Count -eq 0) {
Write-Host -ForegroundColor Green "Arrêt programmé pour le $RebootTime !"
$Result = 1
sleep 5
}else{
Write-Host -ForegroundColor Red "Échec de programmation de l'arrêt. Vérifiez que le format de l'heure saisi est correct et qu'aucun arrêt n'est déjà prévu !"
sleep 60
}