user2885241
user2885241

Reputation: 71

Write output data row to pipe delineated text file in powershell

I am a powershell newbie and I need a script that does a write output to a delineated text file in powershell.

In sequence, this is what I would like to do in powershell:

  1. read data from excel file and store to variables
  2. read data from table in mssql
  3. write output the each row from (2) to a text file (pipe delineated) appending the value from (1)

I was able to figure out sequence 1 and 2 however I am stumped on (3).
Here is a snippet of what i am trying to do:

# Iterate through the dataset
foreach ($row in $ds.tables["location"].rows)
{
Out-file ?
}

Please help!

Upvotes: 1

Views: 2522

Answers (1)

Richard
Richard

Reputation: 109100

$myData | Export-CSV -delimiter '|' -Path $MyFileName

Note, the Export-CSV cmdlet will handle looping over the data, so no need for your own loop.

Upvotes: 3

Related Questions