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

WIMMount (HSM) causing cluster storage to go redirected (2012r2 DC)

Failed to delete the test record dcdiag-test-record in zone test.com

Azure MFA with Azure AD and RDS