I am trying to return List< T> from PowerShell function, but get one of:
PowerShell 5.0 added support for classes and hence methods where the return type can be specified. To control the type returned, use a class with a static method:
class ListManager {
static [System.Collections.Generic.List[int]] Create() {
[System.Collections.Generic.List[int]] $list =
[System.Collections.Generic.List[int]]::new()
$list.Add(3)
return $list
}
}
[ListManager]::Create().GetType()