I was able to sort the column and remove duplicates using -Unique
Import-Csv -Path $csvPath -Header $h | sort id -Unique
My problem is that I can't remove a specific row using the status property
| ID | Name | Status |
|---|---|---|
| 1 | John | Current |
| 1 | John | Future |
| 2 | Mary | Future |
| 2 | Mary | Notice |
| 3 | Paul | Future |
I want the rows to be unique by status order.
- Current
- Notice
- Future
Example: If there's no Current but have Notice and Future, Notice will be selected.
| ID | Name | Status |
|---|---|---|
| 1 | John | Current |
| 2 | Mary | Notice |
| 3 | Paul | Future |
Would you please let me know what I need to add on my script?