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 - Problem with Measure-Object on get-process

Reply
 
Old 08-09-2007   #1 (permalink)
A. Petitjean


 
 

Problem with Measure-Object on get-process

Hi PowerScripters !

I have a strange problem when I run this command :

get-process notepad | format-list * | measure-object

The result is always : 5
Although when I just try "get-process notepad | format-list *" I have a lot
of properties, and not only five !

What's the problem ?

Arnaud
PS: of course, the notepad is launched before...

My System SpecsSystem Spec
Old 08-09-2007   #2 (permalink)
dreeschkind


 
 

RE: Problem with Measure-Object on get-process

The format-* cmdlets are designed to be used only at the end of the
pipeline, not in the middle.
You can use something like this instead to measure properties:

PS> get-process notepad | gm -membertype *property* | measure-object

--
greetings
dreeschkind

"A. Petitjean" wrote:

> Hi PowerScripters !
>
> I have a strange problem when I run this command :
>
> get-process notepad | format-list * | measure-object
>
> The result is always : 5
> Although when I just try "get-process notepad | format-list *" I have a lot
> of properties, and not only five !
>
> What's the problem ?
>
> Arnaud
> PS: of course, the notepad is launched before...

My System SpecsSystem Spec
Old 08-09-2007   #3 (permalink)
dreeschkind


 
 

RE: Problem with Measure-Object on get-process

Oh and btw. "gm" is an alias for get-member.

See: get-member -?

--
greetings
dreeschkind

"dreeschkind" wrote:

> The format-* cmdlets are designed to be used only at the end of the
> pipeline, not in the middle.
> You can use something like this instead to measure properties:
>
> PS> get-process notepad | gm -membertype *property* | measure-object
>
> --
> greetings
> dreeschkind
>
> "A. Petitjean" wrote:
>
> > Hi PowerScripters !
> >
> > I have a strange problem when I run this command :
> >
> > get-process notepad | format-list * | measure-object
> >
> > The result is always : 5
> > Although when I just try "get-process notepad | format-list *" I have a lot
> > of properties, and not only five !
> >
> > What's the problem ?
> >
> > Arnaud
> > PS: of course, the notepad is launched before...

My System SpecsSystem Spec
Old 08-09-2007   #4 (permalink)
A. Petitjean


 
 

RE: Problem with Measure-Object on get-process

Thanks a lot ! It works !

Best regards from France.

Arnaud

"dreeschkind" wrote:

> The format-* cmdlets are designed to be used only at the end of the
> pipeline, not in the middle.
> You can use something like this instead to measure properties:
>
> PS> get-process notepad | gm -membertype *property* | measure-object
>
> --
> greetings
> dreeschkind
>
> "A. Petitjean" wrote:
>
> > Hi PowerScripters !
> >
> > I have a strange problem when I run this command :
> >
> > get-process notepad | format-list * | measure-object
> >
> > The result is always : 5
> > Although when I just try "get-process notepad | format-list *" I have a lot
> > of properties, and not only five !
> >
> > What's the problem ?
> >
> > Arnaud
> > PS: of course, the notepad is launched before...

My System SpecsSystem Spec
Old 08-09-2007   #5 (permalink)
dreeschkind


 
 

RE: Problem with Measure-Object on get-process

And if you really care about these 5 objects that you've been measuring, see
the output of this command:

PS> get-process notepad | format-list * | gm

--
greetings
dreeschkind

"A. Petitjean" wrote:

> Thanks a lot ! It works !
>
> Best regards from France.
>
> Arnaud
>
> "dreeschkind" wrote:
>
> > The format-* cmdlets are designed to be used only at the end of the
> > pipeline, not in the middle.
> > You can use something like this instead to measure properties:
> >
> > PS> get-process notepad | gm -membertype *property* | measure-object
> >
> > --
> > greetings
> > dreeschkind
> >
> > "A. Petitjean" wrote:
> >
> > > Hi PowerScripters !
> > >
> > > I have a strange problem when I run this command :
> > >
> > > get-process notepad | format-list * | measure-object
> > >
> > > The result is always : 5
> > > Although when I just try "get-process notepad | format-list *" I have a lot
> > > of properties, and not only five !
> > >
> > > What's the problem ?
> > >
> > > Arnaud
> > > PS: of course, the notepad is launched before...

My System SpecsSystem Spec
Old 08-09-2007   #6 (permalink)
A. Petitjean


 
 

RE: Problem with Measure-Object on get-process

Ok, but who said that "the format-* cmdlets are designed to be used only at
the end of the pipeline, not in the middle." ??? ;-)

Arnaud

"dreeschkind" wrote:

> And if you really care about these 5 objects that you've been measuring, see
> the output of this command:
>
> PS> get-process notepad | format-list * | gm
>
> --
> greetings
> dreeschkind
>
> "A. Petitjean" wrote:
>
> > Thanks a lot ! It works !
> >
> > Best regards from France.
> >
> > Arnaud
> >
> > "dreeschkind" wrote:
> >
> > > The format-* cmdlets are designed to be used only at the end of the
> > > pipeline, not in the middle.
> > > You can use something like this instead to measure properties:
> > >
> > > PS> get-process notepad | gm -membertype *property* | measure-object
> > >
> > > --
> > > greetings
> > > dreeschkind
> > >
> > > "A. Petitjean" wrote:
> > >
> > > > Hi PowerScripters !
> > > >
> > > > I have a strange problem when I run this command :
> > > >
> > > > get-process notepad | format-list * | measure-object
> > > >
> > > > The result is always : 5
> > > > Although when I just try "get-process notepad | format-list *" I have a lot
> > > > of properties, and not only five !
> > > >
> > > > What's the problem ?
> > > >
> > > > Arnaud
> > > > PS: of course, the notepad is launched before...

My System SpecsSystem Spec
Old 08-09-2007   #7 (permalink)
dreeschkind


 
 

RE: Problem with Measure-Object on get-process

Well, they are designed but not limited to be used at the end of the
pipeline! ;-)
It is not forbidden to use the format-* cmdlets in the middle of the
pipeline, but in general you do not need/want this. The objects produced by
the format-* cmdlets are consumed by the formatting engine. I just wanted to
show you what is really going on behind the scenes in case you were wondering.

--
greetings
dreeschkind

"A. Petitjean" wrote:

> Ok, but who said that "the format-* cmdlets are designed to be used only at
> the end of the pipeline, not in the middle." ??? ;-)
>
> Arnaud
>
> "dreeschkind" wrote:
>
> > And if you really care about these 5 objects that you've been measuring, see
> > the output of this command:
> >
> > PS> get-process notepad | format-list * | gm
> >
> > --
> > greetings
> > dreeschkind
> >
> > "A. Petitjean" wrote:
> >
> > > Thanks a lot ! It works !
> > >
> > > Best regards from France.
> > >
> > > Arnaud
> > >
> > > "dreeschkind" wrote:
> > >
> > > > The format-* cmdlets are designed to be used only at the end of the
> > > > pipeline, not in the middle.
> > > > You can use something like this instead to measure properties:
> > > >
> > > > PS> get-process notepad | gm -membertype *property* | measure-object
> > > >
> > > > --
> > > > greetings
> > > > dreeschkind
> > > >
> > > > "A. Petitjean" wrote:
> > > >
> > > > > Hi PowerScripters !
> > > > >
> > > > > I have a strange problem when I run this command :
> > > > >
> > > > > get-process notepad | format-list * | measure-object
> > > > >
> > > > > The result is always : 5
> > > > > Although when I just try "get-process notepad | format-list *" I have a lot
> > > > > of properties, and not only five !
> > > > >
> > > > > What's the problem ?
> > > > >
> > > > > Arnaud
> > > > > PS: of course, the notepad is launched before...

My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
measure-object works interactively but not in script PowerShell
Adding canonical aliases for Compare-Object, Measure-Object, New-Object PowerShell
Default display for measure-object PowerShell
measure-object {get-process} PowerShell
Multiple errors in help for measure-object 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