title: Windows Batch File - Need to remove line breaks from parameter
body: <p>I have a powershell script that will run a query and export the results to Excel.  I want to hook this into SQL Studio Management Studio (2008)'s external tools.  SSMS will not allow powershell scripts so I am using a batch file to get it started.</p>
  
  <p>In the external tools section you can specify some predefined arguments.  The argument that I want is called "current text".  This argument passes whatever is highlighted to the tool (batch file).  My batch file then passes that argument on to a powershell script.</p>
  
  <p>The problem is that if the user has a query that spans multiple lines highlighted then the powershell script fails because of the linebreaks.  It seems it would be relatively easy to strip them out, or better yet, replace them with a space?</p>
  
  <p>Here is my batch file:</p>
  
  <pre><code>echo %~1
  call powershell ^&amp; 'c:\temp\ExportSQL.ps1' -query "%~1"
  </code></pre>
  
  <p>My question is how can I replace newlines and carriage returns from %1 with a space before passing it to the powershell script?  TIA.</p>