PowerShell 3.0, a single PsCustomObject, and the "count" method


hey guys,

i have custom function outputs pscustomobjects part of loop. example: 

function get-custobj ($j)

{

for ($i=0;$i -lt $j;$i++){write-output ([pscustomobject]@{"key1"="value1";"key2"="value2"})}

}

the problem count number of pscustomobjects instances, including when there 1 instance:

ps c:\users\alee> $a = (get-custobj 2)  ps c:\users\alee> $a.count  2    ps c:\users\alee> $a = (get-custobj 1)  ps c:\users\alee> $a.count  ps c:\users\alee> #note no count returned    ps c:\users\alee>  (get-custobj 1).count  ps c:\users\alee> #note no count returned    ps c:\users\alee> ("one").count  1

is bug? how check if 1 instance returned?

thanks!

explicit cast array: @(get-custobj 1)

ps. think it's bug. please submit bug on  http://connect.microsoft.com


Windows Server  >  Windows PowerShell



Comments

Popular posts from this blog

Generating Event ID 91, 44 with CA (In Event Viewer with source as Certsvc)

Group policy default policy cannot be edited because network name not found

Problem when changing update source