![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| 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) |
| | discovering the type of an object I have written a small function that is helping me to discover the types of PowerShell objects. function WhatTypeIs($obj) { $obj.GetType() | fl UnderlyingSystemType, BaseType } Is there a better way to write that function? |
My System Specs![]() |
| | #2 (permalink) |
| | Re: discovering the type of an object PS> $x = New-Object system.xml.xmldocument PS> WhatTypeIs $x UnderlyingSystemType : System.Xml.XmlDocument BaseType : System.Xml.XmlNode PS> Depends what you wanna know of the object and the corresponding type info. Everthing in PowerShell is an object and has a (hidden) PSObject property to discover more interesting things. Below I define an XML Document object and show ALL the superclasses of the object, upto System.Object. PS> $x = New-Object system.xml.xmldocument PS> $x.psobject.TypeNames System.Xml.XmlDocument System.Xml.XmlNode System.Object "Larry__Weiss" <lfw@xxxxxx> wrote in message news:%23ssNlx4CKHA.4376@xxxxxx Quote: >I have written a small function that is helping me to discover the types of >PowerShell objects. > > function WhatTypeIs($obj) { > $obj.GetType() | fl UnderlyingSystemType, BaseType > } > > Is there a better way to write that function? > |
My System Specs![]() |
| | #3 (permalink) |
| | Re: discovering the type of an object I have the following function in my $profile just to see what types are at the end of the pipe: PS> function Get-Type {$input | %{$_.gettype()} | select name, fullname, basetype -unique} PS> PS> dir | Get-Type | ft -AutoSize Name FullName BaseType ---- -------- -------- DirectoryInfo System.IO.DirectoryInfo System.IO.FileSystemInfo FileInfo System.IO.FileInfo System.IO.FileSystemInfo PS> "Larry__Weiss" <lfw@xxxxxx> wrote in message news:%23ssNlx4CKHA.4376@xxxxxx Quote: >I have written a small function that is helping me to discover the types of >PowerShell objects. > > function WhatTypeIs($obj) { > $obj.GetType() | fl UnderlyingSystemType, BaseType > } > > Is there a better way to write that function? > |
My System Specs![]() |
![]() |
| Thread Tools | |
| |
Similar Threads | ||||
| Thread | Forum | |||
| testing parameter for com object type | PowerShell | |||
| New-Object : Cannot load COM type Excel.Application. | PowerShell | |||
| Passing credential object - what's the type? | PowerShell | |||
| Re: Unable to cast COM object of type 'ADODB.RecordsetClass' to class type 'System.Object[]' | .NET General | |||
| Parse Log files into a strongly type Object | PowerShell | |||