Static analysis is the process of evaluating code without executing it. Static analysis in PowerShell makes use of an Abstract Syntax Tree (AST): a tree-like representation of a block of code.
Static analysis
Abstract syntax tree
The AST in PowerShell is available for any script block, for example:
{ 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 is possible to work down through the...