title: Powershell loop, with sqlplus connection string
body: <p>I want to create a power shell script, that loops a connection string using sqlplus but i am not really sure how to do it in power shell.</p>
  <p>something like:</p>
  <pre><code>begin
    for i in 1..10
    loop
      sqlplus .../...@'(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=...)(HOST=...)(PORT=...)))(CONNECT_DATA=(SID=...)))
      --- wait for response then move foreward
    end loop;
  end
  </code></pre>
  <p>The idea is that i want to test different connection_timeout values in the connection string to determine which value is more stable.</p>
  <p>I have found this piece of powershell code online, but i am not sure how to adjust it for my requirement:</p>
  <pre><code>$lines = Get-Content 'c:\firstsecondnames.txt'
  $DBs = &quot;192.168.1.1&quot;
  $DB = &quot;DBA&quot;
  $ConnectionTimeout = 90
  $QueryTimeout = 90
  
  foreach ($line in $lines) {
      $vala  = $line.Split(',')[0]
      $valb  = $line.Split(',')[1]
      #DB query
      $Query = &quot;select ValC from dbo.PROCESSED_INTERCHANGES where Firstname = '$vala' and middlename = '$valb'&quot;
      $conn=new-object System.Data.SqlClient.SQLConnection
      $ConnectionString = &quot;Server={0};Database={1};Integrated Security=True;Connect Timeout={2}&quot; -f $DBs,$DB,$ConnectionTimeout
      $conn.ConnectionString=$ConnectionString
      $conn.Open()
      $cmd=new-object system.Data.SqlClient.SqlCommand($Query,$conn)
      $cmd.CommandTimeout=$QueryTimeout
      $ds=New-Object system.Data.DataSet
      $da=New-Object system.Data.SqlClient.SqlDataAdapter($cmd)
      [void]$da.fill($ds)
      $conn.Close()
      $conn.Dispose()
      foreach ($valC in $ds.tables[0].rows.ValC) {
          $fullname = $vala + $valb + $valC
        Write-Host $fullname
      }
  
  } 
  </code></pre>