I hail you, Automox Gods
Newbie here, working today with Automox. Day 1. So please bare with me.
I am trying to run a policy for a weekly reboot, but am unable to. Would like to have your input.
This is the script i got:
# Get the last boot up time
$lastBootUpTime = (Get-CimInstance -ClassName Win32_OperatingSystem).LastBootUpTime
# Get the current date and time
$currentDate = Get-Date
# Calculate the time difference in days
$daysSinceLastReboot = ($currentDate - $lastBootUpTime).Days
# Check if the last reboot was more than 7 days ago
if ($daysSinceLastReboot -gt 7)
# If yes, exit to remediation
{
exit 1
}
else
{
exit 0
}
Force automatic restart after worklet completion is ticked, with the deferrals enabled, to run if the the machine is to have the reboot
My first thought was putting that script on the evaluation code, and a simple write output on the remediation code; no go.
I have tried putting exit 1 on the evaluation code and the script on the remediation code; no go.
I have tried removing the exit 0; no go.
Every time i run the policy, i get the popup for the system reboot required. The laptop has a fresh reboot, made manually or made by pressing the reboot now, so, under the 7 days the script requests. Am testing on 3 different devices, on 3 different locations, the outcome is always the same. I force run the policy, and i get the popup with the System Reboot Required, which i should only get if the laptop hadn't had a reboot in two days.
I am sure i am missing something, can i get a little help, please?
Thank you so much