You could try to extract the first 14 characters of each line and parse them as a [datetime]
value, but you don't actually need to do that.
Big-endian date formats (like your YYYYMMddHHmmss
format for example), are alphabetically ordered - that is, if one date predates another, it will also precede it when sorted alphabetically.
That means we can just use a date/time string of the same format, describing the cutoff date, and then compare the lines from the log file to that:
$since = Get-Date (Get-Date).AddYears(-4) -Format 'YYYYMMdd'
# this will only return the last 4 years worth of logs
Get-Content old.log | Where { $_ -gt $since }
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…