I read in one of the forums that there was a need to export the query results into a CSV. Unfortunately, the thread is now closed but the problem is still valid. I have been trying to export the output of a SCCM Query (CMQuery) into a well formatted CSV with header information but there seems to be no way out other than to copy the results and paste it in notepad.
I built a tool to solve this problem. The details of the tool can be found on my blog:
The script has a description on how to use it. Its easy and GUI based. I hope this helps.