Skip to content

Instantly share code, notes, and snippets.

@dfinke
Created June 19, 2025 15:11
Show Gist options
  • Save dfinke/03b8dd1e1908d9376d4f1f6365a08bdc to your computer and use it in GitHub Desktop.
Save dfinke/03b8dd1e1908d9376d4f1f6365a08bdc to your computer and use it in GitHub Desktop.
param(
[int]$Year = (Get-Date).Year,
[int]$Month = (Get-Date).Month
)
# Set up day names
$days = @("Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat")
# Print header
Write-Host ""
Write-Host (" " * 6) -NoNewline
Write-Host ("{0} {1}" -f (Get-Culture).DateTimeFormat.GetMonthName($Month), $Year) -ForegroundColor Yellow
Write-Host ""
# Print day names
foreach ($day in $days) {
Write-Host ("{0,4}" -f $day) -NoNewline
}
Write-Host ""
# Find the first day of the month
$firstDay = Get-Date -Year $Year -Month $Month -Day 1
$startDayOfWeek = [int]$firstDay.DayOfWeek
# Print leading spaces for the first week
for ($i = 0; $i -lt $startDayOfWeek; $i++) {
Write-Host " " -NoNewline
}
# Print days of the month
$daysInMonth = [DateTime]::DaysInMonth($Year, $Month)
for ($day = 1; $day -le $daysInMonth; $day++) {
$currentDate = Get-Date -Year $Year -Month $Month -Day $day
$today = Get-Date
if ($currentDate.Day -eq $today.Day -and $currentDate.Month -eq $today.Month -and $currentDate.Year -eq $today.Year) {
# Highlight today's date in red
Write-Host ("{0,4}" -f $day) -NoNewline -ForegroundColor Red
}
elseif ($currentDate.DayOfWeek -eq 'Friday') {
Write-Host ("{0,4}" -f $day) -NoNewline -ForegroundColor Cyan
}
else {
Write-Host ("{0,4}" -f $day) -NoNewline
}
if ($currentDate.DayOfWeek -eq 'Saturday') {
Write-Host ""
}
}
Write-Host ""
@dfinke
Copy link
Author

dfinke commented Jun 19, 2025

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment