title: PowerShell and bat file logging
body: <p>I wrote a simple script in PowerShell:</p>
  
  <pre><code>############### script #############################
  $Database = @("DatabaseNo1","DatabaseNo2","DatabaseNo3")
  
  Write-Host Running on $Database[0]
  #sqlcmd ...........
  Write-Host Running on $Database[1]
  #sqlcmd ...........
  Write-Host Running on $Database[2]
  #sqlcmd ...........
  Write-Host Stopping...
  #psexec ........
  #############################################
  </code></pre>
  
  <p>This script runs with sqlcmd and psexec and copy commands.
  I need to log PowerShell script activity. 
  Then I wrote bat file which run PowerShell script</p>
  
  <pre><code>#############################################################
  del d:\scripts\log.log
  powershell -file d:\scripts\script.ps1 &gt;&gt; d:\scripts\log.log
  #############################################################
  </code></pre>
  
  <p>I have a problem with formatting the log file.
  This file looks like:</p>
  
  <p>Running on DatabaseNo1Running on DatabaseNo2Running on DatabaseNo3Stoping...</p>
  
  <p>And I want this log to look like:</p>
  
  <p>Running on DatabaseNo1</p>
  
  <p>some data from sqlcmd</p>
  
  <p>Running on DatabaseNo2</p>
  
  <p>some data from sqlcmd</p>
  
  <p>Running on DatabaseNo3</p>
  
  <p>some data from sqlcmd</p>
  
  <p>Stopping...</p>
  
  <p>Some psexec data</p>
  
  <p>etc.</p>