Why does this give me the wrong answer?

Trying to make a script that detects the uptime of a computer. So I want to know if the computer is longer than 10 minutes up.

Using this script always give me the “less than 10” output, even when the uptime of the computer is more than 10.

Anything i’m missing?

function Get-Uptime { $os = Get-WmiObject win32_operatingsystem $uptime = (Get-Date) - ($os.ConvertToDateTime($os.lastbootuptime)) $minutesup = $Uptime.TotalMinutes -replace ',.+$' Write-host $minutesup } Clear-Host Get-Uptime if($minutesup -lt 10) { write-host "less than 10" } else { write-host "more than 10" } 

submitted by /u/ReckyX
[link] [comments]

Leave a Reply