function Get-Friday13th { <# .SYNOPSIS Get Friday the 13th .DESCRIPTION Get the next N Friday the 13ths .EXAMPLE Get-Friday13th #> [Alias('Friday13th', 'Friday13', 'F13')] param( # The number of Friday the 13ths to find (by default, 13) [ValidateRange(1,1kb)] [Alias('Number')] [int] $N = 13, # The starting date (by default, today) [DateTime] $Date = [DateTime]::Now.Date ) $Day = $Date.Date $FridayThe13th = @() do { # Because 5 and 13 are both prime # Any .DayOfWeek * .Day will be 65 if ($day.DayOfWeek * $day.Day -eq 65) { $FridayThe13th += $day } $day = $day.AddDays(1) } while ($FridayThe13th.Count -lt $n) $FridayThe13th } Get-Friday13th