View Single Post
Old 04-03-2007   #2 (permalink)
RichS


 
 

RE: -is [System.Management.Automation.PSCustomObject]

I would stick with gettype() PSCustomObject is I believe a PowerShell
wrapper object for the underlying .NET object. gettype() will return the
underlying type which is what I think you are after
--
Richard Siddaway
Please note that all scripts are supplied "as is" and with no warranty
Blog: http://richardsiddaway.spaces.live.com/
PowerShell User Group: http://www.get-psuguk.org.uk


"Doug" wrote:

> I do an Import-Csv on a file and get False when using the '-is
> [PSCustomObject]' operator the first element .
>
> Should I stick with using .GetType().Name ?
>
> PS > $data = Import-Csv test.csv
> PS > $data[0] | gm
>
>
> TypeName: System.Management.Automation.PSCustomObject
>
> Name MemberType Definition
> ---- ---------- ----------
> Equals Method System.Boolean Equals(Object obj)
> GetHashCode Method System.Int32 GetHashCode()
> GetType Method System.Type GetType()
> ToString Method System.String ToString()
> Age NoteProperty System.String Age=1
> Name NoteProperty System.String Name=John Doe
>
>
> PS > $data[0] -is [object]
> True
> PS > $data[0] -is [System.Management.Automation.PSCustomObject]
> False
> PS > $data[0].GetType().Name
> PSCustomObject
> PS > $data[0].GetType().Name -eq "PSCustomObject"
> True

My System SpecsSystem Spec