You can use a for loop:
$lines = Get-Content -Path "MyFile.txt"
for ($i = 0; $i -lt $lines.Length; $i++){ Write-Host "Reading element $i ..." Write-Host $lines[$i]}Generally, use a for loop if you want to keep track of where you are in an array.
This will return "2"