If I'm Linux, I can use uptime to get such information,like this

PowerShell can do this?


Bit of a different take on this one, using only PowerShell. Using this article as a foundation:

New-TimeSpan -Start (Get-CimInstance -ClassName win32_operatingsystem).LastBootUpTime -End (Get-Date)

This link also shows how you can use Get-WMIObject if you need to.

This one gets a little long.....

New-TimeSpan -Start ((Get-WmiObject win32_operatingsystem | `
Select-Object @{Name='LastBootUptime';Expression={$_.ConverttoDateTime($_.lastbootuptime)}}).lastbootuptime) -End (Get-Date)

From there you can format the object to not have Milliseconds etc.

For example:

New-TimeSpan -Start (Get-CimInstance -ClassName win32_operatingsystem).LastBootUpTime -End (Get-Date) | `
Select-Object Days,Hours

Thanks, Tim.


You can see it with Windows command:

systeminfo|find "Time:"
  • 2
    It depends of the language of your system... – Josem Oct 1 '17 at 8:15

Type net statistics workstation in Powershell to view how long machine has been turned on. It will show the system uptime and since how long the machine has been turned on. Also you can find one more method here- http://www.penguincoders.net/2015/12/find-computer-uptime-in-windows-operating-system.html

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.