I am attempting to run an Action so that when an endpoint reaches its scheduled maintenance window, the system will start patching as scheduled.
I have been just setting the ‘Starts on…’ and ‘Ends on…’ date and times and it has been working flawlessly. However, scheduling over 80 patching actions per month due to varying maintenance windows throughout each week of the month, day of the week and hour of the day/night takes up entirely too much of my time that could be spent doing more productive things.
I found a way to do this by setting variables on each endpoint to set a ‘Patch Window Open’ variable to either True or False. If the system is within the maintenance window, it evaluates to True. If it’s not within the window, it’s evaluates to False.
The variables specify the ‘Patch_Week’ of the month (0-5) beginning with the first Monday as the start of Week 1, the ‘Patch_Day’ (Monday thru Sunday), the ‘Patch_Start_Time’ (4 digit 24-hour time - i.e. 2200 = 10pm), and ‘Patch_End_Time’ (4 digit 24-hour time).
For example:
If the relevance (below) equates to ‘True’, the variable of ‘Patch Window Open’ is set to True, meaning the system is within the maintenance window and can begin patching. The relevance statement is as follows:
===========================================================
if (if current date < (first monday of current month_and_year) then “0” else if current date >= (first monday of current month_and_year) and current date < ((first monday of current month_and_year) + (7*day)) then “1” else if current
date >= ((first monday of current month_and_year) + (7day)) and current date < ((first monday of current month_and_year) + (14day)) then “2” else if current date >= ((first monday of current month_and_year) + (14*day)) and current date
< ((first monday of current month_and_year) + (21day)) then “3” else if current date >= ((first monday of current month_and_year) + (21day)) and current date < ((first monday of current month_and_year) + (28*day)) then “4” else if
current date >= ((first monday of current month_and_year) + (28*day)) then “5” else “Undefined”) = (if exist values of settings “Patch_Week” of client then value of setting “Patch_Week” of client else error “not set”) and day_of_week of
current date as string = (if exist values of settings “Patch_Day” of client then value of setting “Patch_Day” of client else error “not set”) and ((two digit hour of it as string & two digit minute of it as string) of time (local time
zone) of it) of now >= (if exist values of settings “Patch_Start_Time” of client then value of setting “Patch_Start_Time” of client else error “not set”) and ((two digit hour of it as string & two digit minute of it as string) of time
(local time zone) of it) of now <= (if exist values of settings “Patch_End_Time” of client then value of setting “Patch_End_Time” of client else error “not set”) then True else False
This works well and functions properly as long as the maintenance window does not cross over midnight into a new day (i.e. - the maintenance window starts at 10pm and runs until 2am). There are several server groups where this is the case, and thus cannot use the relevance as is currently in place.
I would like to modify the relevance statement to account for a ‘Patch_Start_Day’ and ‘Patch_Start_Time’ as well as a ‘Patch_End_Day’ and ‘Patch_End_Time’ to allow for a window crossing over midnight.
The relevance I currently have for this is not functioning properly and is as follows:
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
if (if current date < (first monday of current month_and_year) then “0” else if current date >= (first monday of current month_and_year) and current date < ((first monday of current month_and_year) + (7day)) then “1” else if current date >= ((first monday of current month_and_year) + (7day)) and current date < ((first monday of current month_and_year) + (14day)) then “2” else if current date >= ((first monday of current month_and_year) + (14day)) and current date < ((first monday of current month_and_year) + (21day)) then “3” else if current date >= ((first monday of current month_and_year) + (21day)) and current date < ((first monday of current month_and_year) + (28day)) then “4” else if current date >= ((first monday of current month_and_year) + (28day)) then “5” else “Undefined”) = (if exist values of settings “Patch_Week” of client then value of setting “Patch_Week” of client else error “not set”) and day_of_week of current date as string = (if exist values of settings “Patch_Start_Day” of client then value of setting “Patch_Start_Day” of client else error “not set”) and ((two digit hour of it as string & two digit minute of it as string) of time (local time zone) of it) of now >= (if exist values of settings “Patch_Start_Time” of client then value of setting “Patch_Start_Time” of client else error “not set”) and ((two digit hour of it as string & two digit minute of it as string) of time (local time zone) of it) of now <= (if exist values of settings “Patch_End_Day” of client then value of setting “Patch_End_Day” of client else error “not set”) and ((two digit hour of it as string & two digit minute of it as string) of time (local time zone) of it) of now >= (if exist values of settings “Patch_End_Time” of client then value of setting “Patch_End_Time” of client else error “not set”) then True else False
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Example screenshot:
I’m no relevance expert by any stretch of the imagination, and would appreciate assistance to get this to function properly.
TIA
Lance