Created
January 31, 2023 02:43
-
-
Save colindix/9a9063220a6712a46f6676559d9607fc to your computer and use it in GitHub Desktop.
Powershell get uptime
This file contains hidden or 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
$cdate = (get-date).ToUniversalTime() ; $bup = ((gcim Win32_OperatingSystem).LastBootupTime).ToUniversalTime(); $ut = (($cdate) - $bup); Write-Output "`nUptime: $($ut.Days)d $($ut.Hours)h $($ut.Minutes)m $($ut.Seconds)s | TotalSeconds: $($ut.TotalSeconds) || Booted: $($bup.ToString('u')) | $(get-date -date $bup -UFormat '%s')`n" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment