Static analysis is the process of evaluating code without executing it. In PowerShell, static analysis makes use of an Abstract Syntax Tree (AST): a tree-like representation of a block of code. AST was introduced with PowerShell 3.
Static analysis
AST
The AST in PowerShell is available for any script block; an example is as follows:
{ Write-Host 'content' }.Ast
The script block that defines a function can be retrieved via Get-Command:
function Write-Content { Write-Host 'content' } (Get-Command Write-Content).ScriptBlock
Or, the script block defining a function can be retrieved using Get-Item:
function Write-Content { Write-Host 'content' }
(Get-Item function:\Write-Content).ScriptBlock
It...