Skip to content

Instantly share code, notes, and snippets.

@Goadstir
Created January 8, 2020 20:42
Show Gist options
  • Select an option

  • Save Goadstir/073ae203473c31f8f7438c92bdccc45a to your computer and use it in GitHub Desktop.

Select an option

Save Goadstir/073ae203473c31f8f7438c92bdccc45a to your computer and use it in GitHub Desktop.
PowerShell: Get the last reboot of the host
# find out last boot time
$os = Get-CimInstance -ClassName Win32_OperatingSystem
$lastBoot = $os.LastBootUpTime
# raw datetime output
$lastBoot
# e.g. \> Wednesday, December 5, 2018 2:31:48 AM
# formatted string output
Get-Date -Date $lastBoot -Format '"Last reboot at" MMM dd, yyyy "at" HH:mm:ss "and" fffff "Milliseconds."'
# e.g. \> Last reboot at Dec 05, 2018 at 02:31:48 and 48526 Milliseconds.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment