Created
June 10, 2020 18:27
-
-
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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