Patch Tuesday
Patch Tuesday – the second Tuesday in the month – is the day Microsoft (and other vendors) release their patches. If you want to be able to plan ahead for these dates ( like arranging holiday or sick leave ) these two functions will supply the dates to look out for.
| 001 002 003 004 005 006 007 008 009 010 011 012 013 014 015 016 017 018 019 020 021 022 023 024 025 026 027 028 029 030 031 032 033 034
| function get-secondTuesday { param([datetime]$date) switch ($date.DayOfWeek){ "Sunday" {$patchTuesday = $date.AddDays(9); break} "Monday" {$patchTuesday = $date.AddDays(8); break} "Tuesday" {$patchTuesday = $date.AddDays(7); break} "Wednesday" {$patchTuesday = $date.AddDays(13); break} "Thursday" {$patchTuesday = $date.AddDays(12); break} "Friday" {$patchTuesday = $date.AddDays(11); break} "Saturday" {$patchTuesday = $date.AddDays(10); break} } $patchTuesday.ToLongDateString() } function Get-PatchTuesday { param ( [parameter(ValueFromPipeline=$true)] [int]$year = (Get-Date).Year, [switch]$nextmonth ) if ($nextmonth){ $now = Get-Date $d = Get-Date -Day 1 -Month $($now.Month + 1) -Year $now.Year get-secondTuesday $d } else { 1..12 | foreach { $d = [datetime]"$_/1/$year" get-secondTuesday $d } } } |
Get-PatchTuesday takes a year (default is current year) and works out the first of each month as a date. This is passed to get-secondtuesday to calculate the date the patches will be released.
If the –nextmonth parameter is used then the first of next month is calculated and the patch date for that month retrieved from getsecondtuesday.
Dates for the next few months are
08 December 2009
12 January 2010
09 February 2010
09 March 2010
13 April 2010
11 May 2010
08 June 2010
13 July 2010
10 August 2010
14 September 2010
12 October 2010
09 November 2010
14 December 2010
Time to start planning.
These functions can be adapted to provide dates for any date that follows the pattern of nth weekday.