Chapter 6 lab, “Learning Powershell in a month of lunches” asks the question “5. Is there a way to eliminate the # comment line from the top of an exported CSV file? That line normally contains type information, but what if you wanted to omit that from a particular file?” but provides no answer. Anyone?
You can provide the parameter -NoTypeInformation to the cmdlets ConvertTo-Csv and Export-Csv.
$data | ConvertTo-Csv -NoTypeInformation
$data | Export-Csv -Path C:\test.csv -NoTypeInformation
The goal was to have you read the help for the command and discover that on your own :). Meant to be empowering.
Thanks Don. Your comment in the book about reading the help ran through my mind after I posted it. And yet I’m not sure what to type after Get-Help.
I went back through the chapters and don’t see where we covered -NoType or how to Get-Help on a switch
Get-help Export-Csv -full
Read the whole entry - especially what each of the parameters do
Its actually a good idea to read through the help for any new cmdlet you come across to make sure you understand how it works an what your choices are
Excellent suggestion, Richard. Thanks very much.
Honestly I should add something similar to every post as a signature.
I personally prefer a web based view:
Get-help Export-Csv -Online