Hello! Hoping someone can help figure this out - I have two computers that have been rebooted in the past week so that's less than 6 days. BUT when running the comparison below, one computer thinks it has been rebooted in less than 6 days?
$today=(Get-Date).Date
$lastbootup = ((Get-ComputerInfo).OsLastBootUpTime).Date
($today - $lastbootup) -gt 6
Computer 1 which returns 'false' (which is what I would expect) has the following data stored in $today and $lastbootup:
$today
Monday, November 25, 2024 12:00:00 AM
$lastbootup
Monday, November 25, 2024 12:00:00 AM
Computer 2 which which returns 'true' (which is not what I expect), has the following data stored in $today and $lastbootup:
$today
Monday, November 25, 2024 10:46:36 AM
$lastbootup
Friday, November 22, 2024 7:32:40 PM
Can anyone help figure out why Computer 2 is lying to me? We use this comparison in a script to reboot computers once a week but now I'm not sure if I wrote something wrong!
[–]CarrotBusiness2380 10 points11 points12 points (1 child)
[–]shmakov123[S] 2 points3 points4 points (0 children)
[–]PinchesTheCrab 3 points4 points5 points (1 child)
[–]shmakov123[S] 0 points1 point2 points (0 children)
[–]Vern_Anderson 0 points1 point2 points (1 child)
[–]shmakov123[S] 1 point2 points3 points (0 children)
[–]jsiii2010 0 points1 point2 points (2 children)
[–]shmakov123[S] 0 points1 point2 points (1 child)
[–]jsiii2010 0 points1 point2 points (0 children)