title: Loop X number of times
body: <p>I'm working on my first PowerShell script and can't figure the loop out.</p>
  
  <p>I have the following, which will repeat <strong><em>$ActiveCampaigns</em></strong> number of times:</p>
  
  <pre><code>Write-Host "Creating $PQCampaign1 Pre-Qualified Report"
  Invoke-Item "$PQCampaignPath1\PQ REPORT $PQCampaign1.qvw"
  Write-Host "Waiting 1 minute for QlikView to update"
  sleep -seconds 60 # Wait 1 minute for QlikView to Reload, create Report and Save.
  
  DO{
      Write-Host "Daily Qlikview Reports"
      Write-Host "Wating for QlikView to create the $PQCampaign1 PQ Report"
      Get-Date
      Write-Host "Checking...."
      sleep -seconds 1
      Write-Host ""
      Write-Host "Not Done Yet"
      Write-Host "Will try again in 5 seconds."
      Write-Host ""
      sleep -seconds 5
  }
  
  Until (Test-Path "$PQCampaignPath1\$PQCampaign1 $PQReportName $ReportDate.xlsx" -pathType leaf)
  
  Get-Date
  Write-Host "Done with $PQCampaign1 PQ Report. Wait 10 seconds."
  sleep -seconds 10
  </code></pre>
  
  <p>These parameters need to increase with one for each loop:</p>
  
  <ul>
  <li><code>$PQCampaign1</code>     (should become <code>$PQCampaign2</code>, then 3, etc.)</li>
  <li><code>$PQCampaignPath1</code>  (should become <code>$PQCampaignPath2</code>, then 3, etc.)</li>
  </ul>
  
  <p>So if <code>$ActiveCampaigns</code> is set to 8 on a certain day, then this needs to repeat 8 times and the last time it must open <code>$PQCampaign3</code> which lies in <code>$PQCampaignPath8</code>.</p>
  
  <p>How can I fix this?</p>