I want to create an agent procedure to reboot a server if it has not rebooted in 30 days. Kaseya knows the date of the last reboot. Is there a way to pull that date from SQL into a variable in an agent procedure, then do the math to see if that date was > 30 days ago?
You can pull that data by using the getvariable command and select SqlView option and using vAgentConfiguration/LastReboot in the entry.
But a much easier way to handle this would be create a view and just select the "Show Machines that have not rebooted in x days"
Then create a policy based on this view to run a reboot procedure.
BroncoMarc, you could use a command like this to pull the last reboot time and then use the data to CheckVar to see if the data is greater than and pull the trigger. I'd test on a few machines to make sure it is being picked up as the proper data type in Kaseya.
powershell -Command "(get-date)-([System.Management.ManagementDateTimeconverter]::ToDateTime((Get-WmiObject win32_operatingsystem).lastbootuptime))| select -ExpandProperty days"
You can use the shelltocommand variable and then query the variable right away...
Hope this is helpful.
That did the trick. That was super simple to use to get the script working! Thanks!
Glad that helped !!!
Share the wealth on the Automation Exchange.