Windows Vista Forums
Vista Forums Home Join Vista Forums Donate Vista Tutorials Tags

Welcome to Vista Forums we are your forum to discuss Windows Vista x64 and x86 systems. Whether you need help or just want to post an idea you have on Vista, this is the forum for you.
Register at Vista forums...the world biggest Windows Vista resource Join Vista Forums Now

Go Back   Vista Forums > Microsoft Technical Newsgroups > PowerShell

Adding new note property

Update your Vista Drivers Update Your Drivers Now!!
Closed Thread
 
Thread Tools Display Modes
Old 07-19-2007   #1 (permalink)
Shay Levi
Guest


 

Adding new note property


Adding new property with "psobject.members.add" method works fine while piping
the object to add-member
returns error.

Am I missing something?


######## add method

PS C:\Scripts> $f = [psobject];
PS C:\Scripts> $np = new-object system.management.automation.PSnoteProperty
hello,"world";
PS C:\Scripts> $f.psobject.members.add($np);
PS C:\Scripts> $f.hello;
world
PS C:\Scripts> $f.psobject.members | ? {$_.MemberType -eq "NoteProperty"}


MemberType : NoteProperty
IsSettable : True
IsGettable : True
Value : world
TypeNameOfValue : System.String
Name : hello
IsInstance : True


######## pipe to add-member

PS C:\Scripts> $f = [psobject];
PS C:\Scripts> $f | add-Member -memberType noteProperty -name hello -value
"world";
PS C:\Scripts> $f.hello;
PS C:\Scripts> $f.psobject.members | ? {$_.MemberType -eq "NoteProperty"}
PS C:\Scripts> $f.hello = "world";
Property 'hello' cannot be found on this object; make sure it exists and
is settable.
At line:1 char:4
+ $f.h <<<< ello = "world"




Shay
http://www.scriptolog.blogspot.com



My System SpecsSystem Spec
Old 07-19-2007   #2 (permalink)
/\/\o\/\/ [MVP]
Guest


 

RE: Adding new note property

for pipeline you need -Passtru parameter

or you can use
add-Member -inputobject $f -memberType noteProperty -name hello -value

Greeinings /\/\o\/\/

"Shay Levi" wrote:

>
> Adding new property with "psobject.members.add" method works fine while piping
> the object to add-member
> returns error.
>
> Am I missing something?
>
>
> ######## add method
>
> PS C:\Scripts> $f = [psobject];
> PS C:\Scripts> $np = new-object system.management.automation.PSnoteProperty
> hello,"world";
> PS C:\Scripts> $f.psobject.members.add($np);
> PS C:\Scripts> $f.hello;
> world
> PS C:\Scripts> $f.psobject.members | ? {$_.MemberType -eq "NoteProperty"}
>
>
> MemberType : NoteProperty
> IsSettable : True
> IsGettable : True
> Value : world
> TypeNameOfValue : System.String
> Name : hello
> IsInstance : True
>
>
> ######## pipe to add-member
>
> PS C:\Scripts> $f = [psobject];
> PS C:\Scripts> $f | add-Member -memberType noteProperty -name hello -value
> "world";
> PS C:\Scripts> $f.hello;
> PS C:\Scripts> $f.psobject.members | ? {$_.MemberType -eq "NoteProperty"}
> PS C:\Scripts> $f.hello = "world";
> Property 'hello' cannot be found on this object; make sure it exists and
> is settable.
> At line:1 char:4
> + $f.h <<<< ello = "world"
>
>
>
>
> Shay
> http://www.scriptolog.blogspot.com
>
>
>

My System SpecsSystem Spec
Old 07-19-2007   #3 (permalink)
Shay Levi
Guest


 

RE: Adding new note property

10x.

The correct form should be

PS C:\Scripts> $f = [psobject];
PS C:\Scripts> $f = $f | add-member noteproperty hello "hi" -passthru
PS C:\Scripts> $f.hello
hi


But still, this doesn't work

PS C:\Scripts> $f = [psobject];
PS C:\Scripts> add-Member -inputobject $f -memberType noteProperty -name
hello -value "hi"
PS C:\Scripts> $f.hello;




Shay
http://www.scriptolog.blogspot.com



> for pipeline you need -Passtru parameter
>
> or you can use
> add-Member -inputobject $f -memberType noteProperty -name hello -value
> Greeinings /\/\o\/\/
>
> "Shay Levi" wrote:
>
>> Adding new property with "psobject.members.add" method works fine
>> while piping
>> the object to add-member
>> returns error.
>> Am I missing something?
>>
>> ######## add method
>>
>> PS C:\Scripts> $f = [psobject];
>> PS C:\Scripts> $np = new-object
>> system.management.automation.PSnoteProperty
>> hello,"world";
>> PS C:\Scripts> $f.psobject.members.add($np);
>> PS C:\Scripts> $f.hello;
>> world
>> PS C:\Scripts> $f.psobject.members | ? {$_.MemberType -eq
>> "NoteProperty"}
>> MemberType : NoteProperty
>> IsSettable : True
>> IsGettable : True
>> Value : world
>> TypeNameOfValue : System.String
>> Name : hello
>> IsInstance : True
>> ######## pipe to add-member
>>
>> PS C:\Scripts> $f = [psobject];
>> PS C:\Scripts> $f | add-Member -memberType noteProperty -name hello
>> -value
>> "world";
>> PS C:\Scripts> $f.hello;
>> PS C:\Scripts> $f.psobject.members | ? {$_.MemberType -eq
>> "NoteProperty"}
>> PS C:\Scripts> $f.hello = "world";
>> Property 'hello' cannot be found on this object; make sure it exists
>> and
>> is settable.
>> At line:1 char:4
>> + $f.h <<<< ello = "world"
>> Shay
>> http://www.scriptolog.blogspot.com



My System SpecsSystem Spec
Old 07-19-2007   #4 (permalink)
/\/\o\/\/ [MVP]
Guest


 

RE: Adding new note property

this works for me :

PoSH> $f = New-Object object
PoSH> add-Member -inputobject $f -memberType noteProperty -name hello
-value "hi"
PoSH> $f

hello
-----
hi

Greetings /\/\o\/\/

"Shay Levi" wrote:

> 10x.
>
> The correct form should be
>
> PS C:\Scripts> $f = [psobject];
> PS C:\Scripts> $f = $f | add-member noteproperty hello "hi" -passthru
> PS C:\Scripts> $f.hello
> hi
>
>
> But still, this doesn't work
>
> PS C:\Scripts> $f = [psobject];
> PS C:\Scripts> add-Member -inputobject $f -memberType noteProperty -name
> hello -value "hi"
> PS C:\Scripts> $f.hello;
>
>
>
>
> Shay
> http://www.scriptolog.blogspot.com
>
>
>
> > for pipeline you need -Passtru parameter
> >
> > or you can use
> > add-Member -inputobject $f -memberType noteProperty -name hello -value
> > Greeinings /\/\o\/\/
> >
> > "Shay Levi" wrote:
> >
> >> Adding new property with "psobject.members.add" method works fine
> >> while piping
> >> the object to add-member
> >> returns error.
> >> Am I missing something?
> >>
> >> ######## add method
> >>
> >> PS C:\Scripts> $f = [psobject];
> >> PS C:\Scripts> $np = new-object
> >> system.management.automation.PSnoteProperty
> >> hello,"world";
> >> PS C:\Scripts> $f.psobject.members.add($np);
> >> PS C:\Scripts> $f.hello;
> >> world
> >> PS C:\Scripts> $f.psobject.members | ? {$_.MemberType -eq
> >> "NoteProperty"}
> >> MemberType : NoteProperty
> >> IsSettable : True
> >> IsGettable : True
> >> Value : world
> >> TypeNameOfValue : System.String
> >> Name : hello
> >> IsInstance : True
> >> ######## pipe to add-member
> >>
> >> PS C:\Scripts> $f = [psobject];
> >> PS C:\Scripts> $f | add-Member -memberType noteProperty -name hello
> >> -value
> >> "world";
> >> PS C:\Scripts> $f.hello;
> >> PS C:\Scripts> $f.psobject.members | ? {$_.MemberType -eq
> >> "NoteProperty"}
> >> PS C:\Scripts> $f.hello = "world";
> >> Property 'hello' cannot be found on this object; make sure it exists
> >> and
> >> is settable.
> >> At line:1 char:4
> >> + $f.h <<<< ello = "world"
> >> Shay
> >> http://www.scriptolog.blogspot.com

>
>
>

My System SpecsSystem Spec
Old 07-23-2007   #5 (permalink)
Keith Hill
Guest


 

Re: Adding new note property

"Shay Levi" <no@addre.ss> wrote in message
news:8766a94431e08c9981a31e87a04@news.microsoft.com...
> 10x.
> The correct form should be
>
> PS C:\Scripts> $f = [psobject];
> PS C:\Scripts> $f = $f | add-member noteproperty hello "hi" -passthru
> PS C:\Scripts> $f.hello
> hi
>
>
> But still, this doesn't work
>
> PS C:\Scripts> $f = [psobject];
> PS C:\Scripts> add-Member -inputobject $f -memberType noteProperty -name
> hello -value "hi"
> PS C:\Scripts> $f.hello;


$f = [psobject]

$f | gm



TypeName: System.RuntimeType

Name MemberType Definition
---- ---------- ----------
Clone Method System.Object Clone()
....


Do you really want to add a new NoteProperty to the RuntimeType object for
System.Management.Automation.PSObject? I think you want to do what MoW
suggests:

$f = new-object object

or

$f = new-object psobject

--
Keith

My System SpecsSystem Spec
Old 07-23-2007   #6 (permalink)
Shay Levi
Guest


 

Re: Adding new note property

Thanks all.

Shay
http://www.scriptolog.blogspot.com



> "Shay Levi" <no@addre.ss> wrote in message
> news:8766a94431e08c9981a31e87a04@news.microsoft.com...
>
>> 10x.
>> The correct form should be
>> PS C:\Scripts> $f = [psobject];
>> PS C:\Scripts> $f = $f | add-member noteproperty hello "hi" -passthru
>> PS C:\Scripts> $f.hello
>> hi
>> But still, this doesn't work
>>
>> PS C:\Scripts> $f = [psobject];
>> PS C:\Scripts> add-Member -inputobject $f -memberType noteProperty
>> -name
>> hello -value "hi"
>> PS C:\Scripts> $f.hello;

> $f = [psobject]
>
> $f | gm
>
> TypeName: System.RuntimeType
>
> Name MemberType Definition
> ---- ---------- ----------
> Clone Method System.Object Clone()
> ...
> Do you really want to add a new NoteProperty to the RuntimeType object
> for System.Management.Automation.PSObject? I think you want to do
> what MoW suggests:
>
> $f = new-object object
>
> or
>
> $f = new-object psobject
>
> --
> Keith



My System SpecsSystem Spec
Closed Thread
Update your Vista Drivers Update Your Drivers Now!!

Thread Tools
Display Modes



Similar Threads
Thread Thread Starter Forum Replies Last Post
A note on saved VMs FACE Virtual PC 0 07-31-2008 05:22 AM
Use my custom TypeDescriptor to obtains default Value on property inXAML Property Editor of Visual Studio 2008 azerty Avalon 0 04-14-2008 06:14 AM
note tclough Vista mail 4 06-24-2007 05:07 AM
Note of Thanks BobS Vista installation & setup 7 02-14-2007 07:23 PM
Re: Adding a ItemConverter property to ItemsControl Raphaƫl Avalon 0 01-10-2006 03:51 PM


Vistax64.com 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 2005-2008

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 47 48 49 50 51