In table.csv there are already columns named Enrolled and Status. There are other columns, but they are not relevant.
| Enrolled | Status |
|---|---|
| 7/28/2021 13:37 | Unknown |
| 7/21/2021 13:37 | Unknown |
| 7/14/2021 13:37 | Unknown |
If Enrolled date is less than 1 week ago from today, the Status cell is changed to PAST DUE
If Enrolled date is greater than 1 week ago from today it becomes DISABLE
If Enrolled date is greater than 2 weeks ago from today it becomes DISABLED STILL PAST DUE
The end result should change table.csv to look like this:
| Enrolled | Status |
|---|---|
| 7/28/2021 13:37 | PAST DUE |
| 7/21/2021 13:37 | DISABLE |
| 7/14/2021 13:37 | DISABLED STILL PAST DUE |
$csv = Import-Csv file.csv
$pastdue = (Get-Date).AddDays(-7)
foreach($i in $csv.Enrolled){
if ($i -lt $pastdue){
???
}
}
I'm thinking the switch function may be useful, but not sure how to implement it.