I have a super easy one here but I cannot figure it out and driving me insane. I suspect it is some kind of scoping issue of the variable (global, etc.?)
Anyway, here is my code:
$i = 0
foreach ($line in Get-Content 'somefile.txt') {
if ($i = 1) {
echo "$i Line: $line"
}
$i++
// I even tried $i = $i + 1
}
Output is $1 = 1 always. It doesn't seem to count.
How can I fix this?
=is an assignment, to compare useif ( $i -eq 1){