OK, I am totally lost on this one. I have this code:
$call1 = "\\mhapp1\Scripts\Tools\MHRebootTool\RebootUtility.exe"
function Get-Uptime {
$o = Get-WmiObject -Class win32_operatingsystem
(Get-Date).date - $o.ConvertToDateTime($o.LastBootUpTime)}
if (($o).TotalDays -gt 7) {&$call1}
Now, what I expect to happen is on any machine that has TotalDays greater than 7 days the &$Call1 should execute. So I have a workstation that has not rebooted for 48 days. I run this script and nothing happens. Yet, when I change the -gt to a -lt then the rebootutility.exe DOES run. why?
on the machine I'm testing on I ran the above code 'without' the IF statement. I replaced the IF statement with Get-Uptime. Here is what Get-Uptime says:
Days : 48
Hours : 13
Minutes : 3
Seconds : 44
Milliseconds : 624
Ticks : 41942246248010
TotalDays : 48.5442664907523
TotalHours : 1165.06239577806
TotalMinutes : 69903.7437466833
TotalSeconds : 4194224.624801
TotalMilliseconds : 4194224624.801