< Back

Find-Namespace

Mon Jan 13, 2020 3:01 am

NAME Find-Namespace



SYNOPSIS

Find namespaces that fit specific criteria.





SYNTAX

Find-Namespace [[-FilterScript] <ScriptBlock>] [[-Name] <String>] [-Force] [-FullName <String>] [-InputObject

<PSObject>] [-Not] [-RegularExpression] [<CommonParameters>]





DESCRIPTION

The Find-Namespace cmdlet searches the AppDomain for namespaces that fit a specific criteria. You can search the

entire AppDomain, specific assemblies, or get the namespace of specific types or members.





PARAMETERS

-FilterScript <ScriptBlock>

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

NamespaceInfo object to evaluate.



Required? false

Position? 0

Default value None

Accept pipeline input? False

Accept wildcard characters? false



-Force [<SwitchParameter>]

If specified non-public namespaces will also be matched. Currently this has no effect.



Required? false

Position? named

Default value False

Accept pipeline input? False

Accept wildcard characters? false



-FullName <String>

Specifies the full namespace name to match.



Required? false

Position? named

Default value None

Accept pipeline input? False

Accept wildcard characters? true



-InputObject <PSObject>

Specifies the current object to evaluate.



Required? false

Position? named

Default value None

Accept pipeline input? True (ByValue)

Accept wildcard characters? false



-Name <String>

Specifies the namespace name to match. The name in this context is the last section of namespace. For

instance, if the namespace was "System.Management.Automation", the name would be "Automation".



Required? false

Position? 0

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



-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



<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.Reflection.AssemblyInfo, System.Type, System.Reflection.MemberInfo, PSObject

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

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



If you pass AssemblyInfo objects as input this cmdlet will return namespaces from that assembly.



If you pass Type or MemberInfo objects as input this cmdlet will return the namespace of that type or member.



If you pass any other object the namespace of that object's type will be returned.





OUTPUTS

ClassExplorer.NamespaceInfo

Matched NamespaceInfo objects will be returned to the pipeline.





NOTES









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



Find-Namespace Automation



# Name FullName Assemblies

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

# Automation System.Management.Automation System.Management.Automation



Find any namespaces with the name "Automation"

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



Get-Assembly System.Xml | Find-Namespace



# Name FullName Assemblies

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

# Xml System.Xml System.Xml, System.Data

# Serialization System.Xml.Serialization System.Xml

# Configuration System.Xml.Serialization.Configuration System.Xml

# Advanced System.Xml.Serialization.Advanced System.Xml

# Schema System.Xml.Schema System.Xml, System.Xml.Linq

# Xsl System.Xml.Xsl System.Xml

# XPath System.Xml.XPath System.Xml, System.Xml.Linq

# Resolvers System.Xml.Resolvers System.Xml

# XmlConfiguration System.Xml.XmlConfiguration System.Xml



Get the assembly with the assembly name "System.Xml" and find all namespaces that it declares types in.

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



Find-Namespace { Find-Member -InputObject $_ -Static -ParameterType runspace }



# Name FullName Assemblies

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

# PowerShell Microsoft.PowerShell Microsoft.PowerShell.ConsoleHost, System...

# Automation System.Management.Automation System.Management.Automation



Find any namespace that has a static member that takes a parameter of the type `runspace`.

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



$namespaces = Find-Namespace -FullName *management*

$namespaces | Find-Namespace -FullName 'Microsoft|Internal' -RegularExpression -Not



# Name FullName Assemblies

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

# Instrumentation System.Management.Instrumentation System.Core, System.Management

# Automation System.Management.Automation System.Management.Automation

# PerformanceData System.Management.Automation.Performa... System.Management.Automation

# Tracing System.Management.Automation.Tracing System.Management.Automation

# Security System.Management.Automation.Security System.Management.Automation

# Provider System.Management.Automation.Provider System.Management.Automation

# Remoting System.Management.Automation.Remoting System.Management.Automation

# WSMan System.Management.Automation.Remoting... System.Management.Automation

# Host System.Management.Automation.Host System.Management.Automation

# Runspaces System.Management.Automation.Runspaces System.Management.Automation

# Language System.Management.Automation.Language System.Management.Automation

# Management System.Management System.Management

# Management System.Web.Management System.Web.Extensions, System.Web



First find all namespaces with the word "management" in their full name, then filter it by namespaces that do not

contain "Microsoft" or "Internal" in their full name.



RELATED LINKS

Online Version: https://github.com/SeeminglyScience/Cla ... mespace.md

Find-Type

Find-Member

Get-Assembly

Get-Parameter