Skip to content

How to check the system up time

If you want to quickly and easily see how long a server has been running for since its last reboot then use this function:

Important Note

This has been updated in March 2026 to use a more modern cmdlet. (Get-WmiObject is now obsolete)

function Get-SystemUptime {
    $os = Get-CimInstance -ClassName Win32_OperatingSystem
    $uptime = (Get-Date) - $os.LastBootUpTime

    [pscustomobject]@{
        Days    = $uptime.Days
        Hours   = $uptime.Hours
        Minutes = $uptime.Minutes
    }
}