PowerShell
Low risk
Show Windows last boot and uptime
Calculates how long Windows has been running without full restart.
$OS = Get-CimInstance Win32_OperatingSystem
$Uptime = (Get-Date) - $OS.LastBootUpTime
[PSCustomObject]@{
DernierDemarrage = $OS.LastBootUpTime
Jours = $Uptime.Days
Heures = $Uptime.Hours
Minutes = $Uptime.Minutes
}
When should you use it?
Use this to confirm whether a workstation really restarted after an update or incident.
What the script does
- Windows exposes the last boot time through Win32_OperatingSystem.
- The script then calculates the elapsed uptime.
Precautions
- Windows Fast Startup can sometimes make a shutdown and power-on look different from a full restart.
Rollback
No changes are made.