Created
December 20, 2017 17:16
-
-
Save turboBasic/a027b76a50cc1daa85d266bd183d6b88 to your computer and use it in GitHub Desktop.
Returns names of all functions declared in Powershell file, excluding all nested functions
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Find-FunctionSimple { | |
Param( | |
[Parameter( Mandatory )] | |
[AllowEmptyString()] | |
[String] | |
$Text | |
) | |
$ast = [System.Management.Automation.Language.Parser]::ParseInput( | |
$Text, | |
[Ref] $Null, | |
[Ref] $Null | |
) | |
$Functions = $ast.FindAll( | |
{ $Args[0] -is [System.Management.Automation.Language.FunctionDefinitionAst] }, | |
$False | |
) | |
$Functions | ForEach-Object Name | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment