What is the PowerShell command to let you know how long a computer has been on

Powershell is rather an amazing powerful scripting tool. For example, Powershell can allow IT pros to automate most of the work
Views: 213
Read Time:36 Seconds

PowerShell is rather an amazing powerful scripting tool. For example, PowerShell can allow IT pros to automate most of the work and allows for remote access and work seamlessly while maintaining the highest level of security.

But for now, we are interested in the PowerShell command that can show us how long a computer has been on:

(Get-Date) - (gcim Win32_OperatingSystem).LastBootUpTime

This command uses the Get-Date cmdlet to get the current date and time, and then subtracts the value of the LastBootUpTime property of the Win32_OperatingSystem class, which returns the date and time the operating system was last started. The result is the amount of time that has elapsed since the last time the computer was started.