Search code examples
powershellpowershell-5.0

Binding 'Delimiter' In Powershell


I know you can use the export-csv feature to quickly export data to a csv file, but I keep getting an error of

Export-csv: can not bind parameter 'Delimiter'.
Can nnot convert value "C:\Test' to type System.Char
Error: String must be exactly one character long

This is my powershell syntax - and the data I want to export can have \ or a - in it

$info = (@'Foxtrot')
foreach ($in in $info)
{
  $Dir = "C:\$in"
  export-csv C:\$in.csv $Dir
}

Solution

  • Try using the parameter names as the -Delimiter is the second parameter e.g.

    Export-Csv -Path "C:\$in.csv" -InputObject $Dir