Why does this come up true? (The Get-Date is set to 18 Right now...) Is it maybe something with the way Get-Date formats the number? I'm stumped....
As a few have said already, you're doing a string comparison rather than a number comparison
$Time = Get-Date -Format %H
$Time.GetType()
IsPublic IsSerial Name BaseType
-------- -------- ---- --------
True True String System.Object
In order to do what you want, you can cast your $Time
to a number
[int]$Time -lt 9
#or with a little trick
+$Time -lt 9
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With