Kaseya Community

Comparing current time of day in script

  • Hello. I am looking for a little help.

    I have a defrag script for workstations that is scheduled to run between 1AM and 4Am in the morning, every Tuesday. Right now, the script is configured to Skip If Offline - so as t not interfere with userstrying to use their PC, if they had not left it on.

    I would like to somehow check the current time of the Agent in an IF statement to see if the current time is between 1AM and 4AM. If so, then call my defrag script. If not, then call a seperate Yes/No prompt sub-script that tells the user that an off-hours defrag was missed, would they like to do it now?

    But I do not know how to check and see if the current Agent time is between 1AM and 4AM in an IF statement in a script.

    Any ideas?

    As always, thanks in advance.


    Legacy Forum Name: Comparing current time of day in script,
    Legacy Posted By Username: lwolf
  • This is achievable with two scripts, but it would really be great to be able to do a bit more in the IF comparison section of scripts. Maybe there is a way....

    With two scripts, use the first script to get the variables you need to compare... compare them if you have to. Call the second script. Use the IF comparison in the second script to determine the action.

    Legacy Forum Name: Scripts Forum,
    Legacy Posted By Username: mparr