Here's my 2-cents using [DateTime]::TryParseExact():
$mmyy = "0524" # user input
$checkDate = (Get-Date).Date
$thisMonth = (Get-Date -Year $checkDate.Year -Month $checkDate.Month -Day 1).Date
if ([DateTime]::TryParseExact($mmyy, 'MMyy', $null, 'None', [ref]$checkDate)) {
# [math]::Sign() returns -1 for a negative value, +1 for a positive value or 0 if the value is 0
switch ([math]::Sign(($checkDate - $thisMonth).Ticks)) {
-1 { "$checkDate is in the past" }
1 { "$checkDate is in the future" }
default { "$checkDate is this month" }
}
}
else {
write-host "Invalid date" -ForegroundColor Red
}