Skip to content

Instantly share code, notes, and snippets.

@colindix
Created January 31, 2023 02:43
Show Gist options
  • Save colindix/9a9063220a6712a46f6676559d9607fc to your computer and use it in GitHub Desktop.
Save colindix/9a9063220a6712a46f6676559d9607fc to your computer and use it in GitHub Desktop.
Powershell get uptime
$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