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 ?
One of the weird quirks about PowerShell is that an operation that
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.