I have an interesting problem for a while. Let's say I have the function
function GetAllFiles($creds, $fld){
$newFiles = New-Object "system.collections.generic.list[string]"
... other stuff which adds entires
return $newFiles
}
On the calling side when I execute
$files = GetAllFiles $creds $fld
$files.Remove("AnExistingEntry")
I get
dir-ls.ps1:Method invocation failed because [System.Object[]] doesn't contain a meth od named 'Remove'.
When I do $newFiles.GetType()
IsPublic IsSerial Name BaseType
-------- -------- ---- --------
True True Object[] System.Array
How can I make it to be "system.collections.generic.list[string]" back?
Thanks