![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| 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. |
| |||||||
![]() |
| |
| | #1 (permalink) |
| | Having hard time with Get-Member The way I see it so far is that Get-member is a very powerful and helpful command when playing with powershell I'm still a newbie with Powershell, but I'm having sometimes hard time to understand few things PS > "hello".length 5 I've learnt about .length by typing PS > "hello" | get-member and I found the property length Length Property System.Int32 Length {get;} I'm reading Power Shell Pocket reference, and I found this example: PS >(dir).Count 2276 So I thought that I will find the count property of dir (or get- childintem) by typing PS > dir | get-member or PS > child-item | get-member but I'm cannot find it Is this normal ? Am I missing something ? |
My System Specs![]() |
| | #2 (permalink) |
| | Re: Having hard time with Get-Member On Nov 22, 9:13*am, Personne <cpdiv...@xxxxxx> wrote: Quote: > The way I see it so far is that Get-member is a very powerful and > helpful command when playing with powershell > > I'm still a newbie with Powershell, but I'm having sometimes hard time > to understand few things > > PS > "hello".length > 5 > > I've learnt about .length by typing > PS > "hello" | get-member > > and I found the property length > Length * * * * * Property * * * * * * *System.Int32 Length {get;} > > I'm reading Power Shell Pocket reference, and I found this example: > > PS >(dir).Count > 2276 > > So I thought that I will find the count property of dir (or get- > childintem) by typing > PS > dir | get-member > or > PS > child-item | get-member > > but I'm cannot find it > > Is this normal ? > Am I missing something ? returns an array will automatically just return the object instead of the array if there is only one element. Count is a property of an array. If only one item is returned, then Count doesn't exist. You can force it to consider the output to be an array by putting @() around the value. Example: (dir some_exact_filename.txt) Will not have a Count property, but @(dir some_exact_filename.txt) will have a Count property. |
My System Specs![]() |
| | #3 (permalink) |
| | Re: Having hard time with Get-Member How did you figure that out ? So following you idea, I tried this (dir some_exact_filename.txt) | get-member *co* and @(dir some_exact_filename.txt) | get-member *co* and no count property show up !!! I'm sad, very sad |
My System Specs![]() |
| | #4 (permalink) |
| | Re: Having hard time with Get-Member On Nov 22, 4:04*pm, Personne <cpdiv...@xxxxxx> wrote: Quote: > How did you figure that out ? > > So following you idea, I tried this > > (dir some_exact_filename.txt) *| get-member *co* > and > @(dir some_exact_filename.txt) *| get-member *co* > > and no count property show up !!! > > I'm sad, very sad Member grabs each item INSIDE the array and processes it. To see the array itself you need to use the input parameter. Try this: gm -in @(dir some_exact_filename.txt) And in my case I found it out by trial and error, but I hope someone out there has a more authoritative (and less frustrating) source to suggest. |
My System Specs![]() |
| | #5 (permalink) |
| | Re: Having hard time with Get-Member Tojo2000 and Shay thank you Because I like to learn, I would like to know where I can find about this ,@(xxx) syntax. I knew about @(xxx) but never see ,@(xxx) before today |
My System Specs![]() |
| | #6 (permalink) |
| | Re: Having hard time with Get-Member Check the Windows PowerShell Team Blog: http://blogs.msdn.com/powershell/arc...owershell.aspx --- Shay Levy Windows PowerShell MVP http://blogs.microsoft.co.il/blogs/ScriptFanatic PowerShell Toolbar: http://tinyurl.com/PSToolbar P> Tojo2000 and Shay thank you P> P> Because I like to learn, I would like to know where I can find about P> this ,@(xxx) syntax. P> I knew about @(xxx) but never see ,@(xxx) before today |
My System Specs![]() |
![]() |
| Thread Tools | |
| |
Similar Threads | ||||
| Thread | Forum | |||
| Add-Member not Adding a member | PowerShell | |||
| my hard disk is working all the time | Vista hardware & devices | |||
| Hard drives work all the time | Vista General | |||
| Why does the hard drive run all the time??? | Vista General | |||
| Being a member of a workgroup and domain at the same time | Vista networking & sharing | |||