Richard's profileRichard Siddaway's BlogPhotosBlogLists Tools Help

Blog


    November 14

    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.

    Technorati Tags: ,,

    Comments

    Please wait...
    Sorry, the comment you entered is too long. Please shorten it.
    You didn't enter anything. Please try again.
    Sorry, we can't add your comment right now. Please try again later.
    To add a comment, you need permission from your parent. Ask for permission
    Your parent has turned off comments.
    Sorry, we can't delete your comment right now. Please try again later.
    You've exceeded the maximum number of comments that can be left in one day. Please try again in 24 hours.
    Your account has had the ability to leave comments disabled because our systems indicate that you may be spamming other users. If you believe that your account has been disabled in error please contact Windows Live support.
    Complete the security check below to finish leaving your comment.
    The characters you type in the security check must match the characters in the picture or audio.

    To add a comment, sign in with your Windows Live ID (if you use Hotmail, Messenger, or Xbox LIVE, you have a Windows Live ID). Sign in


    Don't have a Windows Live ID? Sign up

    Trackbacks

    The trackback URL for this entry is:
    http://richardsiddaway.spaces.live.com/blog/cns!43CFA46A74CF3E96!2617.trak
    Weblogs that reference this entry
    • None