The bellow example
Function Get-ListOfList
{
$listOfLists = New-Object System.Collections.ArrayList
$List = New-Object System.Collections.ArrayList
$List.Add("A") | Out-Null
$List.Add("B") | Out-Null
$listOfLists.Add($List) | Out-Null
return $listOfLists
}
I would expect this to return a single list , with 1 item in it , a list. That list has 2 strings in it.
But what is happening is that it returns a list , with 2 items in it.
$l = Get-ListOfList
$l.Count
$l.GetType().Name
$l[0].Count
$l[0].GetType().Name
$l[1].Count
$l[1].GetType().Name
outputs
2
ArrayList
1
String
1
String
This is messing things up as the behavior is different when the list of list has more then 1 item in it , it returns what you expect.