Q. How can I use Get-Content to read and parse a comma-separated value (CSV) file in PowerShell?

Don't. Anytime you're parsing text, you're probably working too hard. The Import-CSV cmdlet already knows how to parse a CSV file, so just use that.

Don Jones

July 28, 2010

1 Min Read
magnifying glass laying on keyboard

Q. How can I use Get-Content to read and parse a comma-separated value (CSV) file in PowerShell?

A. Don't. Anytime you're parsing text, you're probably working too hard. The Import-CSV cmdlet already knows how to parse a CSV file, so just use that.

Do you have a Windows PowerShell question? Find more PowerShell FAQs, articles, and other resources at windowsitpro.com/go/DonJonesPowerShell.

 

Sign up for the ITPro Today newsletter
Stay on top of the IT universe with commentary, news analysis, how-to's, and tips delivered to your inbox daily.

You May Also Like