Filter object by Type with Powershell Custom Class Types

I am working with a module that uses custom classes. I am using Powershell 5.1 on Windows 10 1703. I need to filter for a specific object type in the return from a module. (Multiple Object types return due to cmdlet code. Not my code.) I have tried to use the -is operator but the custom class doesn’t seem to surface in Typing. This may be an issue with Powershell’s implementation of classes but I am a simple scripter at the moment.

Start by piping an instance of your class to Get-Member, as that’s the easiest way to see what PowerShell thinks the type name is. If the “-is [whatever]” syntax isn’t working, you may instead need to run through a ForEach, pipe each object to Get-Member, and then look at the TypeName property that Get-Member outputs. Or run a Where-Object and directly look at the instances’ TypeName property.

Thank You. I end up using:

$obj|where{($_|get-member).typename -eq 'CustomTypeName'}