`ExternalScriptInfo` does not have property for `CmdletBinding` like `CmdletInfo`
See original GitHub issueExternalScriptInfo
object should expose the property for CmdletBinding
like CmdletInfo
or FunctionInfo
.
The only was to find if the ExternalScriptioInfo
object has CmdletBinding
attribute is to look through the attributes on the ScriptBlock
.
But in the case of the following example, it is considered that the object has CmdletBinding
with the explicit attribute.
param(
[parameter()]
$Path
)
Issue Analytics
- State:
- Created 2 years ago
- Comments:5 (4 by maintainers)
Top Results From Across the Web
about Functions CmdletBindingAttribute - PowerShell
The CmdletBinding attribute is an attribute of functions that makes them operate like compiled cmdlets written in C#.
Read more >ExternalScriptInfo Class (System.Management.Automation)
Provides information for scripts that are directly executable by PowerShell but are not built into the runspace configuration.
Read more >Param in CmdletBinding not mandatory and error ...
1 Answer 1 ... Your parameters are in separate parameter sets (only), so by design they cannot be used together. ... Since your...
Read more >T
Ignore what was passed in, there are no common parameters if cmdlet binding is not used. shouldGenerateCommonParameters = false;.
Read more >PowerShell-Docs/reference/docs-conceptual/lang-spec ...
A collection is a group of one or more related items, which need not have the same type. Examples of collection types are...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
A more concrete example:
We can still get this information by enumerating all parameters from
$c.Parameters
and try to find aParameterAttribute
from any of them, but that’s just too much efforts. I think it would be nice to add theCmdletBinding
property toExternalScriptInfo
, just likeCmdletInfo
andFunctionInfo
.@JamesWTruher Yeah that’s part of the point. A scriptblock is considered to have cmdletbinding if:
[Parameter()]
attributes on any of its parameters.In other words, it’s quite a pain to find the information properly without the proper helper properties that are provided on FunctionInfo and CmdletInfo.