Treating an object as an Array

This is not a new 'problem', maybe not even a problem.
Othetwise a positive respons to 4.64, no problems found.

The followin code will work, dispite the result returned from a com operation is an object
$aUnit is Vartype 9, but can be treated as an array using for each

$oCMS = CreateObject("CapaInstaller.SDK")
$RC = $oCMS.SetDefaultManagementPoint("2")
$aUnit = $oCMS.GetGroupPackages($Group,"Dynamic_SQL")
For Each $item In $aUnit ; This works despite $aUnut is an object type
WriteLog(Split($item,'|')[0])
next

The following code will fail:

$oCMS = CreateObject("CapaInstaller.SDK")
$RC = $oCMS.SetDefaultManagementPoint("2")
$aUnit = $oCMS.GetGroupPackages($Group,"Dynamic_SQL")
For $i = 0 To UBound($aUnit) ; This will not work BECAUSE $aUnut is an object type
WriteLog(Split($aUnit[$i],'|')[0])
next

I am glad that the for each statement works, but the same stament in vbscript has a method of typecating
to declare the returned object as an array, before retrieving it:

Set aUnit = CreateObject("System.Collections.ArrayList")
wscript.echo oCMS.SetDefaultManagementPoint("2")
Set aUnit = oCMS.GetGroupPackages("Test","Static")

Kind Regards
Erik Kærholm