I am trying to figure out if there is a way to combine day/date checks to test the logical condition of whether today is the first Tuesday in the month that follows a Monday in the same month.
That is to say, if Tuesday is the first of the month, it would return False. For that month, it would not return true on any day except the 8th day (following the first Monday on the 7th of the month).
To make it a little more international you could use it like this:
$Today = Get-Date
if ($Today.DayOfWeek.value__ -eq 2 -and $Today.Day -ge 2 -and $Today.Day -le 8 ) {
'Today is the first Tuesday of the month following a Monday of the same month'
}
$Today = Get-Date
if ($Today.DayOfWeek.value__ -eq 2 -and $Today.Day -in 2..8 ) {
'Today is the first Tuesday of the month following a Monday of the same month'
}
it’s Tuesday rules out 6/7 days
its before 9th rules out 2/3ish of the month
then rules out 1st 1/9
as I said the first part that is found as false the rest isn’t evaluated, ok yes we are talking milliseconds or less, but that depends on how often the checks are made. its just good practice to think about running time.
all the solutions are good to be honest, I did like your international modification