[CmdletBinding()]param( [string[]]$Path # Path to script ) BEGIN{} PROCESS{ foreach( $local:scriptPath in $Path ) { $rs = [runspacefactory]::CreateRunspace() $rs.Open() # Get the AST of the file $tokens = $errors = $null $ast = [System.Management.Automation.Language.Parser]::ParseFile( $scriptPath, [ref]$tokens, [ref]$errors) # Get only function definition ASTs $functionDefinitions = $ast.FindAll({ param([System.Management.Automation.Language.Ast] $Ast) $Ast -is [System.Management.Automation.Language.FunctionDefinitionAst] -and # Class methods have a FunctionDefinitionAst under them as well, but we don't want them. ($PSVersionTable.PSVersion.Major -lt 5 -or $Ast.Parent -isnot [System.Management.Automation.Language.FunctionMemberAst]) }, $true) $functionDefinitions } } END{}