How do I create a new variable each time a loop runs?
Something along the lines of
for ($i=1; $i -le 5; $i++) { $"var + $i" = $i write-host $"var + $i }
Use New-Variable and Get-Variable (mind available options including scopes). E.g.
New-Variable
Get-Variable
for ($i=1; $i -le 5; $i++) { New-Variable -Name "var$i" -Value $i Get-Variable -Name "var$i" -ValueOnly }
1.4m articles
1.4m replys
5 comments
57.0k users