Saturday, July 23, 2022

uptime equivalent on Windows

To find out how long a Windows machine has been on, the equivalent of uptime on Linux - https://devblogs.microsoft.com/scripting/powertip-get-the-last-boot-time-with-powershell/

Get-CimInstance -ClassName win32_operatingsystem | select csname, lastbootuptime

Using this in a "Basic Task" with Task Scheduler did not work when not logged on. So, instead of creating a basic task, used "create task" and chose "run whether user is logged in or not." Also enabled run with highest privileges.

No comments:

Post a Comment