powershell outputing results to a file -
I am trying to use Powershell V2.0 to write the content of the SQL query in a file. To write on the console screen, I can successfully use the host CMDlet to write on the console screen, but when I change the write-output, only one result is given in the test.txt file (instead of about 700 ). Why can this be?
foreach ($ line $ $ DataSet.Tables [0] .owsows) {$ name = $ row [0] .strass (). Type trim () - $ name & gt; Test.txt}
You are redirecting to the output file & gt; On every record of (instead of & gt; & gt;) this is causing the file to be rewritten with each record, and you are only left with the final record in the output file.
It should work better:
& Amp; {Foreach ($ R $ Tables in DataSet [0] .row) {$ line [0]. Ostring () .trim ()}} | Set-content test.txt
Comments
Post a Comment