![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
|
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.
br> br> |
| |||||||
![]() |
| | Thread Tools | Display Modes |
| | #1 (permalink) |
| 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 Specs![]() |
| | #2 (permalink) |
| 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 Specs![]() |
| | #3 (permalink) |
| 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 Specs![]() |
| | #4 (permalink) |
| 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 Specs![]() |
| | #5 (permalink) |
| 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 Specs![]() |
| | #6 (permalink) |
| 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 Specs![]() |
![]() |
| 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 |