I am trying to return List< T> from PowerShell function, but get one of:
If you need to return a list of ints, use jachymko's solution.
Otherwise, if you do not particularly care whether what you get is a list or array, but just want to iterate through result, you can wrap result in @() while enumerating, e.g.
$fooList = CreateClrList
foreach ($foo in @($fooList))
{
...
}
That would cause @($fooList)
to be of array type - either an empty array, array with one element or array with multiple elements.