PowerShell 2.0: One Cmdlet at a Time 84 ConvertFrom-CSV

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

What can I do with it?

Convert a series of CSV style strings which have been generated by ConvertTo-CSV back into objects.


Retrieve a list of services beginning with the letter b and convert the object into CSV style strings, storing them into the variable $CSVStrings . Convert these back into objects.

$CSVStrings = Get-Service | Where-Object{$_.Name -like ‘b*’} | ConvertTo-CSV -NoTypeInformation $CSVStrings | Select-Object -First 1 $CSVStrings | ConvertFrom-CSV

You will notice that $CSVStrings contains the same data as for the example in ConvertTo-CSV , cut short for clarity. That variable is piped into ConvertFrom-CSV to change it back.

How could I have done this in PowerShell 1.0?

You could have used Import-CSV, but that would have read the information from a file.

1000 things 1% better!