title: PowerShell loop until variable
body: <p>I have a simple piece of code, that I want to loop until it reaches the variable given by the user (i.e. if the user says 3, loop 3 times)</p>
  
  <pre><code>$quantidade = Read-Host -Prompt 'NUMERO DE INSTANCIAS'
  $loop = 0
  while ($loop -ne $quantidade) {
      $Servers = Read-Host -Prompt 'NOME SQL'
      $Version = Read-Host -Prompt 'VERSAO SQL? (2014,2012,...'
  
      if ($Version -eq "2014") {
          Write-Host "VERSAO 2014"
          $VERSQL = "12"
      } elseif ($Version -eq "2008") {
          Write-Host "VERSAO 2008"
          $VERSQL = "10"
      } elseif ($Version -eq "2012") {
          Write-Host "VERSAO 2012"
          $VERSQL = "11"
      } elseif ($Version -eq "2016") {
          Write-Host "VERSAO 2016"
          $VERSQL = "13"
      } elseif ($Version -eq "2017") {
          Write-Host "VERSAO 2017"
          $VERSQL = "14"
      } else {
          Write-Host "ERRO"
          break
      }
  
      Write-Host "You input server '$Servers' and '$Version'"
  
      $SQL = -join("%ProgramFiles%\Microsoft SQL Server\MSSQL", $VERSQL, ".", $Servers, "\MSSQL\Binn\sqlservr.exe")
  
      Write-Host $SQL
      $loop = $lopp + 1
      Write-Host $loop
  }
  </code></pre>
  
  <p>I know whats wrong, the sum is being done inside the loop, making it always 0+1 =1. Whats the better way to go around this?</p>