First commit

This commit is contained in:
Alexandre Mottier 2020-10-18 22:09:36 +02:00
parent d1291e83c9
commit 1d96015654
3 changed files with 38 additions and 1 deletions

View File

@ -1 +1,19 @@
# ScheduledReboot
# ScheduledReboot
## What is it ?
This script enables you to schedule a restart of a PC or a server at a wanted time.
## How it works ?
When the script is launched, it asks you to set the day of reboot (0 for today, 1 for tomorrow, 2 for after-tomorrow, etc...).
It asks you to set the hour too.
Default : today at 4 AM.
The time must be formatted as a decimal number (2 for 2:00 ; 14,5 for 14:30).
## How to use it ?
2 ways are available : the ps1 (powershell file), or the executable file.
Both are doing the same, but the display is different.
Feel free to contact me at contact@alexandremottier.fr if you have any question.

BIN
ScheduledReboot.exe Normal file

Binary file not shown.

19
ScheduledReboot.ps1 Normal file
View File

@ -0,0 +1,19 @@
# Déclaration des variables
$Date = Read-Host -Prompt "A quelle date doit redémarrer le serveur ? (aujourd'hui : 0 ; demain : 1)"
$Time = Read-Host -Prompt "A quelle heure doit redémarrer le serveur ? (defaut : 4h)"
# Affectation de la valeur par défaut (si non complétion)
if (!$Date)
{
$Date = 0
}
if (!$Time)
{
$Time = 4
}
# Envoi de la commande de shutdown basé sur l'heure saisie
shutdown -r -t ([decimal]::round(((Get-Date).AddDays($Date).Date.AddHours($Time) - (Get-Date)).TotalSeconds))
# Message affichant la bonne prise en compte de la demande
Write-Host "Le redémarrage du serveur a bien été programmé pour $Time h !"