Skip to content

Instantly share code, notes, and snippets.

@realslacker
Last active March 11, 2025 11:06
Show Gist options
  • Save realslacker/541e7490640b00345a8d256e2860406d to your computer and use it in GitHub Desktop.
Save realslacker/541e7490640b00345a8d256e2860406d to your computer and use it in GitHub Desktop.
<#
.SYNOPSIS
Create an .ics file with a calendar of 28 sprints for a year. In each quarter, there are 6 sprints of 14 days each and 1 sprint of 7 days.
.PARAMETER Path
The path to the .ics file to create.
.PARAMETER StartDate
The start date of the first sprint.
.PARAMETER CalendarYear
The year of the calendar.
#>
param(
[Parameter( Mandatory )]
[ValidateScript({
if ( $_.Split('.')[-1] -eq 'ics' ) { return $true }
throw 'Destination path must be an .ics file'
})]
[string]
$Path,
[Parameter( Mandatory )]
[datetime]
$StartDate,
[Parameter( Mandatory )]
[string]
$CalendarYear
)
$NowStamp = [datetime]::Now.ToUniversalTime().ToString('yyyyMMddTHHmmssZ')
$Cal = [System.Collections.Generic.List[string]]@(
'BEGIN:VCALENDAR'
'VERSION:2.0'
'METHOD:PUBLISH'
'PRODID:-//Braunweb//PowerShell ICS Creator Sample//EN'
)
foreach ( $Quarter in 1..4 ) {
foreach ( $Sprint in 1..7 ) {
$SprintLength = $Sprint -lt 7 ? 14 : 7
$Cal.Add( 'BEGIN:VEVENT' )
$Cal.Add( 'UID:{0}' -f [guid]::NewGuid() )
$Cal.Add( 'CREATED:{0}' -f $NowStamp )
$Cal.Add( 'DTSTAMP:{0}' -f $NowStamp )
$Cal.Add( 'LAST-MODIFIED:{0}' -f $NowStamp )
$Cal.Add( 'SEQUENCE:0' )
$Cal.Add( 'DTSTART:{0}' -f $StartDate.ToString('yyyyMMdd') )
$Cal.Add( 'DTEND:{0}' -f $StartDate.AddDays($SprintLength).ToString('yyyyMMdd') )
#'RRULE:FREQ=YEARLY;INTERVAL=1'
#'DESCRIPTION:{0}Q{1}-{2}' -f $StartDate.ToString('yy'), $Quarter, $Sprint
$Cal.Add( ('SUMMARY:{0}Q{1}-{2}' -f $CalendarYear, $Quarter, $Sprint) )
#'LOCATION:" + $eventLocatio'
$Cal.Add( 'TRANSP:TRANSPARENT' )
$Cal.Add( 'END:VEVENT' )
$StartDate = $StartDate.AddDays($SprintLength)
}
}
$Cal.Add( 'END:VCALENDAR' )
$Cal | Set-Content -Path $Path -Encoding UTF8
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment