Ast is a PowerShell module for using the PowerShell abstract syntax tree (AST) to analyze PowerShell code. It provides commands to extract functions, commands, aliases, comments, and script structure from a file, a string of script content, or an existing AST object.
Install the module from the PowerShell Gallery:
Install-PSResource -Name Ast
Import-Module -Name AstThe commands accept a file path (-Path) or inline script content (-Script), and default to matching everything so
you can narrow the results with -Name.
Get-AstFunction -Path ./MyScript.ps1
Get-AstFunctionName -Path ./MyScript.ps1Get-AstCommand -Path ./MyScript.ps1
Get-AstCommand -Script "Get-Process; Write-Host 'Hello'"Get-AstFunction -Path ./MyScript.ps1 -Name 'Test-Me'Documentation is published at psmodule.io/Ast.
Use PowerShell help and command discovery for module details:
Get-Command -Module Ast
Get-Help -Name Get-AstFunction -Examples- lzybkr/ShowPSAst — an interactive viewer for exploring the PowerShell AST.