Windows Vista Forums
Vista Forums Home Join Vista Forums Webcasts Windows 7 Forum 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

accessing the extended type system from C#

Update your Vista Drivers Update Your Drivers Now!!
Closed Thread
 
Thread Tools Display Modes
Old 10-08-2006   #1 (permalink)
klumsy@xtra.co.nz
Guest


 

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
Guest


 

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
Guest


 

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]
Guest


 

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
Guest


 

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
Closed Thread

Thread Tools
Display Modes



Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: Unable to cast COM object of type 'ADODB.RecordsetClass' to class type 'System.Object[]' Michel Posseth [MCP] .NET General 2 03-27-2008 10:04 AM
Accessing System 32 and COM API's for Vista thru Powershell Spooky PowerShell 3 12-17-2007 08:38 AM
system lockup when accessing large files from IDE nabeel46 Vista General 3 09-30-2007 06:08 PM
Getting Operating System and Chasis type through wmi greatbarrier86 PowerShell 28 08-15-2007 07:44 PM
Accessing Collection type items using Negative Index Numbers DBMwS PowerShell 3 07-02-2006 08:11 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