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 - How do I change the type of "Value" in PSNoteProperty

Reply
 
Old 07-31-2008   #1 (permalink)
AgentM


 
 

How do I change the type of "Value" in PSNoteProperty

I have a PSObject being returned that has a PsnoteProperty added.
the Value of this PsNoteProperty is a Collection of PSObjects.

PsObject.Properties.Add( new PsProperty("Name",Value))

Now when I try to read this Value, it comes in as a object.
How do I loop through these objects?




My System SpecsSystem Spec
Old 07-31-2008   #2 (permalink)
AgentM


 
 

RE: How do I change the type of "Value" in PSNoteProperty

I am using C# to build a cmdlet.

"AgentM" wrote:
Quote:

> I have a PSObject being returned that has a PsnoteProperty added.
> the Value of this PsNoteProperty is a Collection of PSObjects.
>
> PsObject.Properties.Add( new PsProperty("Name",Value))
>
> Now when I try to read this Value, it comes in as a object.
> How do I loop through these objects?
>
>
>
My System SpecsSystem Spec
Old 08-01-2008   #3 (permalink)
Shay Levy [MVP]


 
 

RE: How do I change the type of "Value" in PSNoteProperty

Hi AgentM,


I can't tell much about C# but in PowerShell I would use the foreach statment,
I guess you can do the same in C#:

foreach($o in $objPsNoteProperty ) {$o.propertyName ...}




---
Shay Levy
Windows PowerShell MVP
http://blogs.microsoft.co.il/blogs/ScriptFanatic



A> I am using C# to build a cmdlet.
A>
A> "AgentM" wrote:
A>
Quote:
Quote:

>> I have a PSObject being returned that has a PsnoteProperty added. the
>> Value of this PsNoteProperty is a Collection of PSObjects.
>>
>> PsObject.Properties.Add( new PsProperty("Name",Value))
>>
>> Now when I try to read this Value, it comes in as a object. How do I
>> loop through these objects?
>>

My System SpecsSystem Spec
Old 08-01-2008   #4 (permalink)
AgentM


 
 

RE: How do I change the type of "Value" in PSNoteProperty

No you can't do foreach, "object" doesn't inherit from Ienumerable

"Shay Levy [MVP]" wrote:
Quote:

> Hi AgentM,
>
>
> I can't tell much about C# but in PowerShell I would use the foreach statment,
> I guess you can do the same in C#:
>
> foreach($o in $objPsNoteProperty ) {$o.propertyName ...}
>
>
>
>
> ---
> Shay Levy
> Windows PowerShell MVP
> http://blogs.microsoft.co.il/blogs/ScriptFanatic
>
>
>
> A> I am using C# to build a cmdlet.
> A>
> A> "AgentM" wrote:
> A>
Quote:
Quote:

> >> I have a PSObject being returned that has a PsnoteProperty added. the
> >> Value of this PsNoteProperty is a Collection of PSObjects.
> >>
> >> PsObject.Properties.Add( new PsProperty("Name",Value))
> >>
> >> Now when I try to read this Value, it comes in as a object. How do I
> >> loop through these objects?
> >>
>
>
>
My System SpecsSystem Spec
Old 08-01-2008   #5 (permalink)
RickB


 
 

Re: How do I change the type of "Value" in PSNoteProperty

But you said the property's value was a collection.
Wouldn't you be casting it to a collection and thereby making it
enumerable.

AgentM wrote:
Quote:

> No you can't do foreach, "object" doesn't inherit from Ienumerable
>
> "Shay Levy [MVP]" wrote:
>
Quote:

> > Hi AgentM,
> >
> >
> > I can't tell much about C# but in PowerShell I would use the foreach statment,
> > I guess you can do the same in C#:
> >
> > foreach($o in $objPsNoteProperty ) {$o.propertyName ...}
> >
> >
> >
> >
> > ---
> > Shay Levy
> > Windows PowerShell MVP
> > http://blogs.microsoft.co.il/blogs/ScriptFanatic
> >
> >
> >
> > A> I am using C# to build a cmdlet.
> > A>
> > A> "AgentM" wrote:
> > A>
Quote:

> > >> I have a PSObject being returned that has a PsnoteProperty added. the
> > >> Value of this PsNoteProperty is a Collection of PSObjects.
> > >>
> > >> PsObject.Properties.Add( new PsProperty("Name",Value))
> > >>
> > >> Now when I try to read this Value, it comes in as a object. How do I
> > >> loop through these objects?
> > >>
> >
> >
> >
My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
error code 39 on all device type: "Modems" & "Ports (COM & LPT)" Vista hardware & devices
Change width on INPUT TYPE="Button" VB Script
How to change permanently the "Text Size" under "View"? Vista mail
How to change the "license to" name on the "About" Vista Home wind Vista General
Change a filetype's "edit with" independent of "open with"? Vista file management


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