Get Windows uptime using PowerShell

Need to know how long your Windows system has been running? Fire up PowerShell and try this:

$LastBoot = ([WMI]'').ConvertToDateTime((gwmi win32_operatingsystem).LastBootUpTime)
$Diff = (Get-Date) - $LastBoot
Write-Host "Last Boot $LastBoot, Uptime" $Diff.Duration()

Leave a Reply

Your email address will not be published. Required fields are marked *