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?
$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]
}
Apparently there is another post about this, but I tried the suggestion listed as the answer it still gives me the same error.