Skip to content

Instantly share code, notes, and snippets.

@turboBasic
Created December 20, 2017 17:16
Show Gist options
  • Save turboBasic/a027b76a50cc1daa85d266bd183d6b88 to your computer and use it in GitHub Desktop.
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
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