Parameters, Static vs Dynamic

I have two questions.

  1. Is it possible to have a dynamic parameter’s .Parameter help context appear in get-help?

  2. Similar question in having the “syntax” portion of get-help to show a dynamic parameter?

Love this community!

Dynamic parameters do not show in help or syntax because they are processed at runtime. Depending on what you are trying to accomplish, you can use Parameter Sets. Basically, if you use a -Foo switch then add or remove available parameters passed to a function. It would be easier to provide a scenario and expected results so that advice can be given specifically on your goal(s).

Perhaps converting to a static variable will be easier so that documentation is possible.

I’d like to have the $meversion parameters ValidateSet property set to the results of the following (if the folder list changes, the validate set changes):
–> $arrSet = Get-ChildItem -Path \server\me-backups_Installs_AutoInstall\ -Directory | Select-Object -ExpandProperty Name

I’ll write it as I think of it, then hopefully the result can be crafted as a static parameters vs. using a dynamic one.

function install-me {
[ValidateSet(Get-ChildItem -Path \server\me-backups_Installs_AutoInstall\ -Directory | Select-Object -ExpandProperty Name)]

You may be able to do this if you switch to XML help files. Comment-based help definitely won’t work here, but XML files are pretty much displayed as-is.