1 2 3 4 5 6 7 8 9 10 11 12 | $code = { Get-Process Get-Service $var2 = 12 } [System.Management.Automation.PSParser]::Tokenize($code,[ref]$null) | ForEach-Object { if ($_.Type -eq 'Command') { $_.content } } |
1 2 3 4 5 6 7 8 9 10 11 12 | $code = { Get-Process Get-Service $var2 = 12 } [System.Management.Automation.PSParser]::Tokenize($code,[ref]$null) | ForEach-Object { if ($_.Type -eq 'Command') { $_.content } } |