[Solved] Parse existing CSV file and strip certain columns


If you want the columns removed completely:

$CSV = Import-Csv $Path | Select-Object -Property User1, Name, Gender
$CSV | Export-Csv $NewPath -NoTypeInformation

Or this, if it’s easier:

$CSV = Import-Csv $Path | Select-Object -Property * -ExcludeProperty Age, Location, HairColor
$CSV | Export-Csv $NewPath -NoTypeInformation

If you want the columns to remain but be empty:

$CSV = Import-Csv $Path | Select-Object -Property User1, Name, @{n='Age';e={}}, @{n='Location';e={}}, Gender, @{n='HairColor';e={}}
$CSV | Export-Csv $NewPath -NoTypeInformation

solved Parse existing CSV file and strip certain columns