Powershell CSV删除没有标题名的列

Powershell CSV删除没有标题名的列,powershell,Powershell,我无法从CSV文件中选择特定列。我只需要选择2列: 1002 2019-02-01 00:03:07 以下是我的例子: (Get-Content c:\Users\file.csv) -replace ',', "`t" -replace '/', '-' | foreach { $_ + "`t 1 `t 255 `t 1 `t 0" } | Select -Skip 1 | Set-Content C:\Users\outfile.csv 我现在的输出: 1002

我无法从CSV文件中选择特定列。我只需要选择2列:

1002 2019-02-01 00:03:07

以下是我的例子:

(Get-Content c:\Users\file.csv)  -replace ',', "`t" -replace '/', '-'  | 
  foreach { $_ + "`t 1 `t 255 `t 1 `t 0" } | 
  Select -Skip 1 | 
  Set-Content C:\Users\outfile.csv
我现在的输出:

1002    Hafiz   New Organization    9-6-2019 13:57  Check In    'Main1_Door1_Entrance Card Reader1  Main1_Door1_Entrance Card Reader1    1   255     1   0
1002    Hafiz   New Organization    9-6-2019 15:44  Check In    'Main1_Door1_Entrance Card Reader1  Main1_Door1_Entrance Card Reader1    1   255     1   0
最终结果:

 3006   2019-02-01 00:03:07     1   255 1   0
 1005   2019-02-01 06:44:31     1   255 1   0

PowerShell有一个内置的
导入Csv
命令。这避免了自己手动解析CSV文件的需要。你可以这样做:

Import-Csv -Path c:\Users\file.csv | Select-Object -Property Column1, Column2

请添加输入CSV文件的前三行或前四行,以及您希望这些行在输出中的外观。现在,您还没有提供enuf信息来判断什么将按预期工作。