Currently, when I want to list what parameters a function has, I can call (Get-Command fn).Parameters. When I want to do the same with scriptblock, I have to use $block.Ast and manually parse the parameters from the AST, which is quite convoluted. It would be much more convenient if the same .Parameters attribute worked for scriptblocks.
Add .Parameters property to [scriptblock] that returns same output as on [System.Management.Automation.FunctionInfo]
You can do a quick workaround for the same currently:
$function:temp = $scriptblock
(Get-Command temp -CommandType function).Parameters
Remove-Item function:temp
That's an awesome hack, thanks. :)
It'd be nice if you could just cast a scriptblock to ScriptInfo. Giving it a public constructor that takes ScriptBlock and pulls ExecutionContext from TLS would be great.
Most helpful comment
You can do a quick workaround for the same currently: