powersell variable scope include:global,script,private,local.
I test a variable in loop, bug why it have value outside loop?
$a=$false
for ($i = 0; $i -lt 10; $i++) {
$private:recObj=@{}
$private:recObj.id=$i
if ($i -lt 6) {
$a=$true
}else {
$a=$false
}
$private:recObj.a=$a
$private:recObj.b="2323"
}
$private:recObj #recObj is private, why here have output? I want it is null
the result:
Name Value
---- -----
b 2323
id 9
a False