<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.technet.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Hey, Scripting Guy! How Do I Create a CSV File from Within Windows PowerShell?</title><link>http://blogs.technet.com/b/heyscriptingguy/archive/2009/07/09/hey-scripting-guy-how-do-i-create-a-csv-file-from-within-windows-powershell.aspx</link><description>Hey Scripting Guy! I am having a problem trying to create a CSV file from within Windows PowerShell. I thought at first I could use the Write-Host cmdlet to do this. I came up with this command: 
 Write-Host "col1,col2,col3" &amp;gt;&amp;gt; "C:\fso\test.csv</description><dc:language>en-US</dc:language><generator>Telligent Evolution Platform Developer Build (Build: 5.6.50428.7875)</generator><item><title>re: Hey, Scripting Guy! How Do I Create a CSV File from Within Windows PowerShell?</title><link>http://blogs.technet.com/b/heyscriptingguy/archive/2009/07/09/hey-scripting-guy-how-do-i-create-a-csv-file-from-within-windows-powershell.aspx#3437061</link><pubDate>Thu, 23 Jun 2011 13:21:11 GMT</pubDate><guid isPermaLink="false">d5e57398-b9ef-4490-9955-07cbb4e4a80d:3437061</guid><dc:creator>jrv</dc:creator><description>&lt;p&gt;UPDATE:&lt;/p&gt;
&lt;p&gt;This blog was for POwerShellV1,&lt;/p&gt;
&lt;p&gt;Here is the solution for PowerShell V2 &lt;/p&gt;
&lt;p&gt;$path = &amp;quot;c:\fso\bios1.csv&amp;quot;&lt;/p&gt;
&lt;p&gt;Get-WmiObject -Class win32_bios | Select name,version | Export-Csv $path -NoTypeInfo&lt;/p&gt;
&lt;p&gt;V2 has a CmdLet for creating a CSV.&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.technet.com/aggbug.aspx?PostID=3437061" width="1" height="1"&gt;</description></item><item><title>re: Hey, Scripting Guy! How Do I Create a CSV File from Within Windows PowerShell?</title><link>http://blogs.technet.com/b/heyscriptingguy/archive/2009/07/09/hey-scripting-guy-how-do-i-create-a-csv-file-from-within-windows-powershell.aspx#3437015</link><pubDate>Thu, 23 Jun 2011 07:41:17 GMT</pubDate><guid isPermaLink="false">d5e57398-b9ef-4490-9955-07cbb4e4a80d:3437015</guid><dc:creator>thiru</dc:creator><description>&lt;p&gt;When i execute this code i get the following error&lt;/p&gt;
&lt;p&gt;Exception calling &amp;quot;CreateTextFile&amp;quot; with &amp;quot;2&amp;quot; argument(s): &amp;quot;Exception from HRESULT: 0x800A&lt;/p&gt;
&lt;p&gt;004C (CTL_E_PATHNOTFOUND)&amp;quot;&lt;/p&gt;
&lt;p&gt;At line:6 char:28&lt;/p&gt;
&lt;p&gt;+ $file = $fso.CreateTextFile &amp;lt;&amp;lt;&amp;lt;&amp;lt; ($path,$true)&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp;+ CategoryInfo &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;: NotSpecified: (:) [], MethodInvocationException&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp;+ FullyQualifiedErrorId : ComMethodTargetInvocation&lt;/p&gt;
&lt;p&gt;$path = &amp;quot;c:\fso\bios1.csv&amp;quot;&lt;/p&gt;
&lt;p&gt;$bios = Get-WmiObject -Class win32_bios&lt;/p&gt;
&lt;p&gt;$csv = &amp;quot;Name,Version`r`n&amp;quot;&lt;/p&gt;
&lt;p&gt;$csv +=$bios.name + &amp;quot;,&amp;quot; + $bios.version&lt;/p&gt;
&lt;p&gt;$fso = new-object -comobject scripting.filesystemobject&lt;/p&gt;
&lt;p&gt;$file = $fso.CreateTextFile($path,$true)&lt;/p&gt;
&lt;p&gt;$file.write($csv)&lt;/p&gt;
&lt;p&gt;$file.close()&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.technet.com/aggbug.aspx?PostID=3437015" width="1" height="1"&gt;</description></item></channel></rss>