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 - accessing the extended type system from C#

Reply
 
Old 10-08-2006   #1 (permalink)
klumsy@xtra.co.nz


 
 

accessing the extended type system from C#

say i create a pipeline and run "dir c:\". i get returned a
Collection<PSobject> . from this i can get the baseobject for whether
its a fileinfo or directoryinfo etc.. however how can i get the
extended type system properties.. i.e the PSdrive, PSiscontainer etc
etc?

Karl


My System SpecsSystem Spec
Old 10-08-2006   #2 (permalink)
klumsy@xtra.co.nz


 
 

Re: accessing the extended type system from C#

(bool)psobj.Properties["psiscontainer"].Value

seems to be the way.
no method to list the properties?

My System SpecsSystem Spec
Old 10-08-2006   #3 (permalink)
Adam Milazzo


 
 

Re: accessing the extended type system from C#

klumsy@xtra.co.nz wrote:
> (bool)psobj.Properties["psiscontainer"].Value
>
> seems to be the way.
> no method to list the properties?


Well if psobj.Properties is a collection, you can probably enumerate the
key/value pairs.
My System SpecsSystem Spec
Old 10-10-2006   #4 (permalink)
Bruce Payette [MSFT]


 
 

Re: accessing the extended type system from C#

Correct. You can use the properties collection to get all the properties,
the methods collection to get all the methods or just use the members
collection to get everything. This works from within PowerShell as well:

PS (116) > (ls)[0].psobject


Members : {PSPath, PSParentPath, PSChildName, PSDrive...}
Properties : {PSPath, PSParentPath, PSChildName, PSDrive...}
Methods : {get_Name, get_Parent, CreateSubdirectory, Create...}
ImmediateBaseObject : figures_appendix
BaseObject : figures_appendix
TypeNames : {System.IO.DirectoryInfo, System.IO.FileSystemInfo,
System.MarshalByRefObject
, System.Object}

-bruce

--
Bruce Payette [MSFT]
Windows PowerShell Technical Lead
Microsoft Corporation
This posting is provided "AS IS" with no warranties, and confers no rights.
Visit the Windows PowerShell Team blog at:
http://blogs.msdn.com/PowerShell
Visit the Windows PowerShell ScriptCenter at:
http://www.microsoft.com/technet/scr.../hubs/msh.mspx


"Adam Milazzo" <adamm@san.rr.com> wrote in message
news:uIop%23Zx6GHA.4608@TK2MSFTNGP03.phx.gbl...
> klumsy@xtra.co.nz wrote:
>> (bool)psobj.Properties["psiscontainer"].Value
>>
>> seems to be the way.
>> no method to list the properties?

>
> Well if psobj.Properties is a collection, you can probably enumerate the
> key/value pairs.



My System SpecsSystem Spec
Old 10-10-2006   #5 (permalink)
klumsy@xtra.co.nz


 
 

Re: accessing the extended type system from C#

yeah, i have been enumeratimng the psobject properties.

Bruce Payette [MSFT] wrote:
> Correct. You can use the properties collection to get all the properties,
> the methods collection to get all the methods or just use the members
> collection to get everything. This works from within PowerShell as well:
>
> PS (116) > (ls)[0].psobject


woah... that a neat trick. its interesting because the psobject
properties doesn't show up in get-member i.e

(ls)[0] | gm doesn't show a psobject property

another supercool trick to add to the collection

My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
Vista 64 System needs Extended warm-up Vista General
Solved Error accessing system registry General Discussion
Re: Unable to cast COM object of type 'ADODB.RecordsetClass' to class type 'System.Object[]' .NET General
system lockup when accessing large files from IDE Vista General
Accessing Collection type items using Negative Index Numbers PowerShell


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