::::::::: PowerShell :::::::::
Sunday, December 11, 2005
  Strange "Get-Member" behavior(Title borrowed from Mow's blog)
Ok, it was weird that whenever I was trying to see if a returned value if of a type array or a scalar.

I have been frusted to see foreach or .length property of output to see if the returned value is an array or not.

But I don't think I would have to worry about it no more.

Strangely enough,

MSH>((get-help get-childitem)."#comment") | gm

would result in displaying type information for type of stored information in the result array object instead of displaying the type of actual array.

But apparently there was at least one another person who was having the similiar problem.

Mow gave me the answer on Usenet newsgroup post and
Here is the answer he posted.


MSH>,((get-help get-childitem)."#comment") | gm

TypeName: System.Management.Automation.MshObject[]


Note that, only difference here was that "," is used to before piping the output to "gm".


For more extensive coverage and answer for this behavior, I recommend
/\/\o\/\/ on MSH (Monad): Create System Variable From MSH (Part2)

If you read through his blog, there is another way to retrieve type information of the array.

gm -input ((get-help get-childitem)."#comment")

Apparently this latter solution works as well.
But why?

Thanks /\/\o\/\/ for another tip there :)
 
Comments:
latter option does not use the Pipeline.

yet another option,

((get-help get-childitem)."#comment").gettype().getmembers()| ft

gr /\/\o\/\/
 
Post a Comment



<< Home
Let's get lazy with PowerShell!

Name:
Location: Flushing, NY, United States

Experimenting with a different format of blogs...

Links
ARCHIVES
10/01/2005 - 11/01/2005 / 11/01/2005 - 12/01/2005 / 12/01/2005 - 01/01/2006 / 01/01/2006 - 02/01/2006 / 02/01/2006 - 03/01/2006 / 03/01/2006 - 04/01/2006 / 04/01/2006 - 05/01/2006 / 05/01/2006 - 06/01/2006 / 06/01/2006 - 07/01/2006 / 07/01/2006 - 08/01/2006 / 08/01/2006 - 09/01/2006 / 10/01/2006 - 11/01/2006 / 11/01/2006 - 12/01/2006 /


Powered by Blogger