Skip to content

Instantly share code, notes, and snippets.

@BanterBoy
Created June 10, 2020 18:27
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save BanterBoy/97d7766ad8bb24b72215b1d41a055f3c to your computer and use it in GitHub Desktop.
Save BanterBoy/97d7766ad8bb24b72215b1d41a055f3c to your computer and use it in GitHub Desktop.
PowerShell function to show you when the next patch Tuesday will occur. You can also specify month/year to find historical or future dates.
function Get-PatchTue {
<#
.SYNOPSIS
Get the Patch Tuesday of a month
.PARAMETER month
The month to check
.PARAMETER year
The year to check
.EXAMPLE
Get-PatchTue -month 6 -year 2015
.EXAMPLE
Get-PatchTue June 2015
#>
param(
[string]$month = (get-date).month,
[string]$year = (get-date).year)
$firstdayofmonth = [datetime] ([string]$month + "/1/" + [string]$year)
(0..30 | ForEach-Object {
$firstdayofmonth.adddays($_)
} |
Where-Object {
$_.dayofweek -like "Tue*"
})[1]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment