![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| 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. |
| |||||||
![]() |
| |
| | #1 (permalink) |
| | 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 Specs![]() |
| | #2 (permalink) |
| | 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 Specs![]() |
| | #3 (permalink) |
| | 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 Specs![]() |
| | #4 (permalink) |
| | 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 Specs![]() |
| | #5 (permalink) |
| | 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 Specs![]() |
![]() |
| 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 | |||