This was an interesting problem that I’ve actually encountered a few times.
I’ve created a site workflow that can be scheduled to run once a year. By populating a collection with values from 1 to 12, using a Regular Expression control, I could loop through every month repeating the process needed.
I calculated the first day of every month, using the year portion of the current date:
Then I got the day of the week for this date:
The next step was to calculate the date of Patch Tuesday, using the previous result and this table:
Day of Week
Days to Patch Tuesday
To facilitate this I used a Switch control.
All that was left now was a Parallel Action control calculating the dates for each server and creating the event:
While I was busy writing this, a colleague, involved with server patching, asked if this can be changed to take public holidays into account.
If the public holidays exist in the same calendar when this workflow is running, a simple Query List control searching for these entries should be enough to adjust the date until it falls on a business day, depending on your specific needs.