Search code examples
c#powershellpsobject

Collection<PSObject> to CSV output


Is there a nice way to convert Collection<PSObject> to CSV output?

Collection<PSObject> psResult = pipeline.Invoke();

Tried pipeline.ToCsv(); Also psResult.ToCsv()

Any ideas?


Solution

  • Add the ConvertTo-Csv cmdlet to your pipeline.

    The Collection<PSObject> returned will consist of comma-separated strings, easily converted to IEnumerable<string> or string[]