I'm trying to delete rows from csv base off certain conditions in two columns. Status column if it has T and the second column is Term Date if the date is older then the past 5 days.
little info column STATUS has either "A" or "T".
$path = "data.csv"
$maxAge = (Get-Date).AddDays(-5).Date
Import-Csv $path | Where-Object {$_.STATUS -eq "A" -or $_.TERMDATE -gt $maxAge} |
Export-Csv -Path temp.csv -NoTypeInformation
it works to a certain degree, but still shows dates from last year.
[datetime]$_.TERMDATE -gt $maxAgein your condition.$_.TERMDATEis going to be a string when read from CSV. It is likely not accurate for your comparison.