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 - One thing to watch for when using assign values via a pipeline

Reply
 
Old 01-04-2008   #1 (permalink)
Bob Landau


 
 

One thing to watch for when using assign values via a pipeline

What ever is feeding the pipe _must_ always return a valid value for the
type being assigned to.

I have written a script which is almost ready for submitting to the script
center it will allow you to find the members of any type

Get-Framework-Help [some type] -typename

will work on type literals where Get-Member doesn't. The format it returns
is identical to Get-Member (please bare with me I'll get to the point)

Here is my pseudo code

Build_MemberDefinition
{
return MemberDefinitions _only_ for what maps to a PSMemberType
}

< Pipeline expression used to find the type, name, etc>
| $description += Build_MemberDefinition $_

*** if ($description -eq $null) { return failure}

The line starred is what took several hours to find in part because the
failure didn't occur all the time.

Even though the starred line evaluated to true; I could dump the contents of
$description as well as verify see that the array had a number of element
count was > 1 so I knew it wasn't NULL.

In the back of my head remembered reading that -eq will enumerate the
entire array or collection and TRUE if there is a match but it didn't click.

Since I didn't instanciate a class for ctor/event, NULL was returned.
Trouble is it's $null is very difficult to see. This is the only way I was
able to find it

$description | % {if ($_ -eq $null) {echo 'true'}}

and this is why $description -eq $null returned true



My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
Assign a Comment VB Script
Assign playback to WMP Vista music pictures video
How assign extension to app? Vista General
how to assign values to array and how to create array via variable PowerShell
Cannot assign drive letter Vista installation & setup


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