Function Test {
[CmdletBinding(DefaultParameterSetName = 'DefaultParameterSet')] param()
DynamicParam {
Write-Host 'Test'
}
}
Test should only appear once when using the help like: Test -?
Test -?
Test
Test
Test
Test
NAME
test
SYNTAX
test [<CommonParameters>]
ALIASES
None
REMARKS
None
I don't think this is a big deal but has a performance impact on the help functions
Name Value
---- -----
PSVersion 7.0.3
PSEdition Core
GitCommitId 7.0.3
OS Microsoft Windows 10.0.18363
Platform Win32NT
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0鈥
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0
Oh, PowerShell sometime re-evaluates things ... This is not always a problem. This is not a problem in this example (until dynamic parameter requests expensive resource). If this was during the work of the pipeline (on hot path), then this would be a problem - have you an example with hot path?
No, I have no example of a hot path. I was just experiencing a slightly longer delay (in e.g. the WhereObject example of #13746) using the -? option in comparison with using no/another option. It is also a bit confusing while debugging dynamic parameters.
You could investigate to ensure there is not extra calls. But I expectation it comes from DynamicParam nature - dependency on current context.
This happens in other places, If you call your function Test-Thing test- [tab] will also cause the dynamic parameters to be evaluated. I've seen this where a module has hundreds of dynamic params each making multiple calls to a server. Tab got really slow. It's one more reason to avoid them
Most helpful comment
This happens in other places, If you call your function
Test-Thingtest- [tab] will also cause the dynamic parameters to be evaluated. I've seen this where a module has hundreds of dynamic params each making multiple calls to a server. Tab got really slow. It's one more reason to avoid them