-
-
Save ltao31/cac25da7a49c072a611838c415970e44 to your computer and use it in GitHub Desktop.
Gets the last bootup time for a windows system
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<# | |
.SYNOPSIS | |
Get the system boot time | |
.DESCRIPTION | |
This PowerShell script gives the system boot time. | |
The format is Year,month,day, hour, minutes, seconds, milliseconds, and timezone. | |
.EXAMPLE | |
PS> ./GetSystemBoottime | |
#> | |
try { | |
$operatingSystem = Get-WmiObject Win32_OperatingSystem | |
"$($operatingSystem.LastBootUpTime)" | |
exit 0 # success | |
} catch { | |
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" | |
exit 1 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment