Created
January 8, 2020 20:42
-
-
Save Goadstir/073ae203473c31f8f7438c92bdccc45a to your computer and use it in GitHub Desktop.
PowerShell: Get the last reboot of the host
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
| # 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