Posted: . At: 6:50 AM. This was 2 years ago. Post ID: 16241
Page permalink. WordPress uses cookies, or tiny pieces of information stored on your computer, to verify who you are. There are cookies for logged in users and for commenters.
These cookies expire two weeks after they are set.


How to use Powershell to print the current uptime of your computer on Windows.


This simple one-liner for Powershell will print the current uptime of your PC. This is printed with multiple columns but it also may be printed on one line.

PS C:\Users\Windows 11> (get-date) - (gcim Win32_OperatingSystem).LastBootUpTime
 
 
Days              : 0
Hours             : 0
Minutes           : 41
Seconds           : 27
Milliseconds      : 915
Ticks             : 24879150105
TotalDays         : 0.0287953126215278
TotalHours        : 0.691087502916667
TotalMinutes      : 41.465250175
TotalSeconds      : 2487.9150105
TotalMilliseconds : 2487915.0105

This example prints everything on one line. This prints the proper date and time when the PC was booted up into Windows 11.

PS C:\Users\Intel i5> (gcim Win32_OperatingSystem).LastBootUpTime | Foreach {($_ -split '\s:',4)[0..2]}
04/27/2022 05:29:02

This is the perfect solution to print the information you need.


Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.