PowerShell 2.0: One Cmdlet at a Time 83 ConvertTo-CSV

Continuing the series looking at new cmdlets available in PowerShell 2.0. This time we look at the ConvertTo-CSV cmdlet.

What can I do with it?

Convert a .NET object into a series of CSV style strings.


Retrieve a list of services beginning with the letter b and convert the object into CSV style strings

Get-Service | Where-Object{$_.Name -like ‘b*’} | ConvertTo-CSV -NoTypeInformation

You will notice that the data returned from the services has been converted into strings separated by a comma. (The names of the services are highlighted in yellow.)

How could I have done this in PowerShell 1.0?

You could have used Export-CSV, but that would have put the information into a file.

1000 things 1% better!