title: Powershell how to pipe an interactive command
body: <p>I am connection to a database via an interactive SQL-Command-Line-Utility and when I am executing an SQL command, I want to pipe the output to another power shell cmdlet, for example out-gridview.</p>
  
  <p>Lets say for example I connect to a Sybase ASE database, and I login with</p>
  
  <pre><code>C:\users\user&gt;isql -U&lt;user&gt; -S&lt;SI&gt;
  [password]:
  1&gt;use master
  2&gt;go
  1&gt;SELECT * FROM sysusers
  2&gt;go | out-gridview
  </code></pre>
  
  <p>The pipe to out-gridview, nor any other cmdlet, is working. I can redirect the output to a file via > nonetheless, but I think its pre-implemented in the isql-command-line-utility.</p>
  
  <p>Has anyone an idea how to pipe this stuff? I am well aware that there are scripts like this</p>
  
  <pre><code>$query="select * from syslogins"
  $conn=New-Object System.Data.Odbc.OdbcConnection
  $conn.ConnectionString= "driver={Adaptive Server Enterprise};
  dsn=SERVER_NAME;db=master;na=IP,PORT;uid=SOMEUSER;pwd=******;"
  $conn.open()
  $cmd=new-object System.Data.Odbc.OdbcCommand($query,$conn)
  $cmd.CommandTimeout=30
  write-host $query
  $ds=New-Object system.Data.DataSet
  $da=New-Object system.Data.odbc.odbcDataAdapter($cmd)
  write-host $ds
  $da.fill($ds)
  $ds.Tables[0] | out-gridview
  $conn.close()
  </code></pre>
  
  <p>But I dont' want to store my password in clear text inside of a script. I want to login to a session, then execute the commands and then pipe my information.</p>