I have the following code:
$CompletedCount = 0
$ArrayName1 = @('test','test1','test2')
$ArrayName2 = @('test3','test4','test5')
$Array = 0
while($true)
{
Write-Host $CompletedCount
$CompletedCount =2
if ($CompletedCount -gt 0)
{
$Array++
$ArrayToDo = "ArrayName{0}" -f $Array
Write-Host "Starting with $ArrayToDo"
foreach ($Name in $ArrayToDo)
{
Write-Host $ArrayToDo.Length
$Name
}
Start-Sleep -Seconds 5
}else
{
Write-Host "not able to start new batch, sleeping"
Start-Sleep -Seconds 10
}
}
in the line foreach ($Name in $ArrayToDo) I want it to show the values in $ArrayName1 but the only thing it does is print 10 and ArrayName1 . Why doesn't 'fetch' the Array-Variable and show its values?
Get-Variable-->(Get-Variable $ArrayToDo -ValueOnly).Length