title: My script is giving the error "Index was outside bounds of array" Powershell
body: <p>I'm writing a script and have been running into the error described in the title. My code is below. I've tried even outputting "$i" and it shows the expected values, so I'm not sure why it is giving me the error. When it gets to the "Write-Host" line, it doesn't even output it. What am I missing?</p>
  
  <pre><code>$LogName = @() #Declaration of an empty array
  
  $NumberOfLogs = Read-Host -Prompt "How many logs do you want to retrieve?" 
  for ($i=0
  $i -lt $NumberOfLogs
  $i++) 
  { 
  $j = $i+1
  $LogName[$i] = Read-Host -Prompt "Enter name of Log #$j"
  Write-Host $LogName[$i]
  }
  </code></pre>
  
  <p>Apparently there is another post about this, but I tried the suggestion listed as the answer it still gives me the same error.</p>