Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > PowerShell

Vista - Get-Member -InputObject returns generic data; bug?

Reply
 
Old 06-20-2006   #1 (permalink)
Alex K. Angelopoulos [MVP]


 
 

Get-Member -InputObject returns generic data; bug?

If I do this:

Get-Command | Get-Member

I get back members of CmdletInfo objects. However, if I do this:
$gcm = Get-Command; Get-Member -InputObject $gcm
or this:
Get-Member -InputObject $(Get-Command)
I get back System.Object[] information.

From my understanding of InputObject, behavior should be the same whether I
am piping objects in or supplying them via InputObject. Is this a bug?




My System SpecsSystem Spec
Old 06-20-2006   #2 (permalink)
Wei Wu [MSFT]


 
 

Re: Get-Member -InputObject returns generic data; bug?

This behavior is by design.
We don't unravel InputObject, therefore you are applying get-member on an
array of CmdletInfo objects when you do "Get-Member -InputObject $gcm".
While in the pipeline scenario, you are applying get-member on each
individual CmdletInfo object.

--
Wei Wu [MSFT]
Windows PowerShell Team
Microsoft Corporation
This posting is provided "AS IS" with no warranties, and confers no rights.


"Alex K. Angelopoulos [MVP]" <a k a @ m v p s . o r g> wrote in message
news:eXX7aVGlGHA.4828@TK2MSFTNGP04.phx.gbl...
> If I do this:
>
> Get-Command | Get-Member
>
> I get back members of CmdletInfo objects. However, if I do this:
> $gcm = Get-Command; Get-Member -InputObject $gcm
> or this:
> Get-Member -InputObject $(Get-Command)
> I get back System.Object[] information.
>
> From my understanding of InputObject, behavior should be the same whether
> I am piping objects in or supplying them via InputObject. Is this a bug?
>
>
>



My System SpecsSystem Spec
Old 06-20-2006   #3 (permalink)
Alex K. Angelopoulos [MVP]


 
 

Re: Get-Member -InputObject returns generic data; bug?

OK. And I can actually use that behavior.

"Wei Wu [MSFT]" <wwu@microsoft.com> wrote in message
news:erzQbjIlGHA.3776@TK2MSFTNGP03.phx.gbl...
> This behavior is by design.
> We don't unravel InputObject, therefore you are applying get-member on an
> array of CmdletInfo objects when you do "Get-Member -InputObject $gcm".
> While in the pipeline scenario, you are applying get-member on each
> individual CmdletInfo object.
>
> --
> Wei Wu [MSFT]
> Windows PowerShell Team
> Microsoft Corporation
> This posting is provided "AS IS" with no warranties, and confers no
> rights.
>
>
> "Alex K. Angelopoulos [MVP]" <a k a @ m v p s . o r g> wrote in message
> news:eXX7aVGlGHA.4828@TK2MSFTNGP04.phx.gbl...
>> If I do this:
>>
>> Get-Command | Get-Member
>>
>> I get back members of CmdletInfo objects. However, if I do this:
>> $gcm = Get-Command; Get-Member -InputObject $gcm
>> or this:
>> Get-Member -InputObject $(Get-Command)
>> I get back System.Object[] information.
>>
>> From my understanding of InputObject, behavior should be the same whether
>> I am piping objects in or supplying them via InputObject. Is this a bug?
>>
>>
>>

>
>



My System SpecsSystem Spec
Old 06-20-2006   #4 (permalink)
dreeschkind


 
 

Re: Get-Member -InputObject returns generic data; bug?

"Wei Wu [MSFT]" wrote:

> This behavior is by design.
> We don't unravel InputObject, therefore you are applying get-member on an
> array of CmdletInfo objects when you do "Get-Member -InputObject $gcm".
> While in the pipeline scenario, you are applying get-member on each
> individual CmdletInfo object.


Yeah, at first I got confused by that behavior too, but I think this design
makes sense once you got the difference.
It should be well documented in the online help though, if it isn't already.

--
greetings
dreeschkind
My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
Generic Class: Passing Data Type to Placeholder .NET General
Initializing a generic SortedList with sorted data .NET General
how to do Generic.List.BinarySearch on byRef data? .NET General
Add-Member -InputObject $s -MemberType ScriptMetho PowerShell
-inputobject vs. receiving from the pipe... PowerShell


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46