< Back

Find-Member

Mon Jan 13, 2020 3:00 am

NAME Find-Member



SYNOPSIS

Find properties, methods, fields, etc that fit specific criteria.





SYNTAX

Find-Member [-Abstract] [-FilterScript <ScriptBlock>] [-Force] [-IncludeSpecialName] [-InputObject <PSObject>]

[-Instance] [-MemberType {Constructor | Event | Field | Method | Property | TypeInfo | Custom | NestedType | All}]

[-Not] [-ParameterType <Type>] [-RegularExpression] [-ReturnType <Type>] [-Static] [-Virtual] [<CommonParameters>]



Find-Member [-Abstract] [-Force] [-IncludeSpecialName] [-InputObject <PSObject>] [-Instance] [-MemberType

{Constructor | Event | Field | Method | Property | TypeInfo | Custom | NestedType | All}] [-Name <String>] [-Not]

[-ParameterType <Type>] [-RegularExpression] [-ReturnType <Type>] [-Static] [-Virtual] [<CommonParameters>]





DESCRIPTION

The Find-Member cmdlet searches the AppDomain for members that fit specified criteria. You can search the entire

AppDomain, search in specific types, or filter an existing list of members.





PARAMETERS

-Abstract [<SwitchParameter>]

If specified only abstract members will be matched..



Required? false

Position? named

Default value False

Accept pipeline input? False

Accept wildcard characters? false



-FilterScript <ScriptBlock>

Specifies a ScriptBlock to invoke as a filter. The variable "$_" or "$PSItem" contains the current member to

evaluate.



Required? false

Position? named

Default value None

Accept pipeline input? False

Accept wildcard characters? false



-Force [<SwitchParameter>]

If specified non-public members will also be matched.



Required? false

Position? named

Default value False

Accept pipeline input? False

Accept wildcard characters? false



-IncludeSpecialName [<SwitchParameter>]

If specified "SpecialName" members will also be matched. This includes accessors like "get_PropertyName",

"set_PropertyName", etc.



Required? false

Position? named

Default value False

Accept pipeline input? False

Accept wildcard characters? false



-InputObject <PSObject>

Specifies the current object to evaluate.



Required? false

Position? named

Default value None

Accept pipeline input? True (ByValue)

Accept wildcard characters? false



-Instance [<SwitchParameter>]

If specified only members visible on an instance of a class will be matched. In other words, members that are

not static.



Required? false

Position? named

Default value False

Accept pipeline input? False

Accept wildcard characters? false



-MemberType <MemberTypes>

Specifies the type of member to return. You can specify multiple member types.



Required? false

Position? named

Default value None

Accept pipeline input? False

Accept wildcard characters? false



-Name <String>

Specifies the member name to match.



Required? false

Position? named

Default value None

Accept pipeline input? False

Accept wildcard characters? true



-Not [<SwitchParameter>]

Specifies that this cmdlet should only return object that do not match the criteria.



Required? false

Position? named

Default value False

Accept pipeline input? False

Accept wildcard characters? false



-ParameterType <Type>

Specifies a type that a member must accept as a parameter to be matched. This parameter will also match base

types, implemented interfaces, and the element type of array, byref, pointer and generic types.



Required? false

Position? named

Default value None

Accept pipeline input? False

Accept wildcard characters? false



-RegularExpression [<SwitchParameter>]

If specified any parameter that accepts wildcards will switch to matching regular expressions.



Required? false

Position? named

Default value False

Accept pipeline input? False

Accept wildcard characters? false



-ReturnType <Type>

Specifies a type that a member must return to match. This includes property types, field types, and method

return types. This parameter will also match base types, implemented interfaces, and the element type of

array, byref, pointer and generic types.



Required? false

Position? named

Default value None

Accept pipeline input? False

Accept wildcard characters? false



-Static [<SwitchParameter>]

If specified only static members will be matched.



Required? false

Position? named

Default value False

Accept pipeline input? False

Accept wildcard characters? false



-Virtual [<SwitchParameter>]

If specified only virtual members will be matched.



Required? false

Position? named

Default value False

Accept pipeline input? False

Accept wildcard characters? false



<CommonParameters>

This cmdlet supports the common parameters: Verbose, Debug,

ErrorAction, ErrorVariable, WarningAction, WarningVariable,

OutBuffer, PipelineVariable, and OutVariable. For more information, see

about_CommonParameters (https:/go.microsoft.com/fwlink/?LinkID=113216).



INPUTS

ClassExplorer.NamespaceInfo, System.Type, System.Reflection.MemberInfo, PSObject

If you pass NamespaceInfo objects to this cmdlet it will match members from types declared in that namespace.



If you pass Type objects to this cmdlet it will match members from that type.



If you pass MemberInfo objects as input this cmdlet will return the input if it matches the specified

criteria. You can use this to chain Find-Member commands to filter output.



If you pass any other type to this cmdlet it will match members from that object's type.





OUTPUTS

System.Reflection.MemberInfo

Matched MemberInfo objects will be returned to the pipeline.





NOTES









-------------------------- EXAMPLE 1 --------------------------



Find-Member GetPowerShell



# ReflectedType: System.Management.Automation.ScriptBlock

#

# Name MemberType IsStatic Definition

# ---- ---------- -------- ----------

# GetPowerShell Method False PowerShell GetPowerShell(Object[] args)

# GetPowerShell Method False PowerShell GetPowerShell(Boolean isTrustedInput, Obj...

# GetPowerShell Method False PowerShell GetPowerShell(Dictionary`2 variables, Obj...

# GetPowerShell Method False PowerShell GetPowerShell(Dictionary`2 variables, Dic...

# GetPowerShell Method False PowerShell GetPowerShell(Dictionary`2 variables, Dic...



Find all members in the AppDomain with the name "GetPowerShell"

-------------------------- EXAMPLE 2 --------------------------



Find-Member -ReturnType System.Management.Automation.Language.Ast -Static



# ReflectedType: System.Management.Automation.CommandCompletion

#

# Name MemberType IsStatic Definition

# ---- ---------- -------- ----------

# MapStringInputToP... Method True Tuple`3 MapStringInputToParsedInput(String input, In...

#

# ReflectedType: System.Management.Automation.Language.UsingExpressionAst

#

# Name MemberType IsStatic Definition

# ---- ---------- -------- ----------

# ExtractUsingVariable Method True VariableExpressionAst ExtractUsingVariable(UsingExpr...

#

# ReflectedType: System.Management.Automation.Language.Parser

#

# Name MemberType IsStatic Definition

# ---- ---------- -------- ----------

# ParseFile Method True ScriptBlockAst ParseFile(String fileName, Token[]& t...

# ParseInput Method True ScriptBlockAst ParseInput(String input, Token[]& tok...

# ParseInput Method True ScriptBlockAst ParseInput(String input, String fileN...



Find all static members in the AppDomain that return any type of AST.

-------------------------- EXAMPLE 3 --------------------------



Find-Member -ParameterType runspace -Virtual



# ReflectedType: System.Management.Automation.Host.IHostSupportsInteractiveSession

#

# Name MemberType IsStatic Definition

# ---- ---------- -------- ----------

# PushRunspace Method False Void PushRunspace(Runspace runspace)

#

#

# ReflectedType: Microsoft.PowerShell.Internal.IPSConsoleReadLineMockableMethods

#

# Name MemberType IsStatic Definition

# ---- ---------- -------- ----------

# RunspaceIsRemote Method False Boolean RunspaceIsRemote(Runspace runspace)



Find all virtual members in the AppDomain that take any runspace type as a parameter.

-------------------------- EXAMPLE 4 --------------------------



Find-Member Parse* -ParameterType System.Management.Automation.Language.Token



# ReflectedType: System.Management.Automation.Language.Parser

#

# Name MemberType IsStatic Definition

# ---- ---------- -------- ----------

# ParseFile Method True ScriptBlockAst ParseFile(String fileName, Token[]& ...

# ParseInput Method True ScriptBlockAst ParseInput(String input, Token[]& to...

# ParseInput Method True ScriptBlockAst ParseInput(String input, String file...



Find all members that start with the word Parse and take Token as a parameter. This example also demonstrates how

this will even match the element of a type that is both an array and ByRef type.

-------------------------- EXAMPLE 5 --------------------------



$members = Find-Member -Force

$members.Count

# 286183



Find all members in the AppDomain including non-public.



RELATED LINKS

Online Version: https://github.com/SeeminglyScience/Cla ... -Member.md

Find-Type

Find-Namespace

Get-Assembly

Get-Parameter