# Function Dynamic Parameter

**URL:** <https://forums.powershell.org/t/function-dynamic-parameter/17302>\
**Category:** PowerShell Help\
**Created:** [August 16, 2021, 3:27pm UTC](https://forums.powershell.org/t/function-dynamic-parameter/17302 "2021-08-16T15:27:05Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![TheBackupGuy](https://avatars.discourse-cdn.com/v4/letter/t/ebca7d/32.png) [@TheBackupGuy](https://forums.powershell.org/u/TheBackupGuy)\
**Post date:** [August 16, 2021, 3:27pm UTC](https://forums.powershell.org/t/function-dynamic-parameter/17302/1 "2021-08-16T15:27:05Z")

</div>

Hello Everyone,

Is it possible to create a dynamic parameter that is generated from a command output?

Today I have a function that would pull a list of vCenters from our backup application via API. If possible, I would like my function to disable/enable backups on one of the vCenters that was generated from my get-vcenters function to be the list of my validated set in my execute-maintenance function.

Example:  
get-vcenters function returns a list of vCenter name

execute-maintenance -action \<disableBackups/enableBackups\> -vCenter \<output\_from\_get-vcenters\>

My end goal is to have a list of vCenters that will automatically be updated, and remove the need to have to constantly update the CSV list of vCenters in the script.

---

<div class="post-metadata">

**Author:** ![matt-bloomfield](https://avatars.discourse-cdn.com/v4/letter/m/dec6dc/32.png) [@matt-bloomfield](https://forums.powershell.org/u/matt-bloomfield)\
**Post date:** [August 16, 2021, 9:28pm UTC](https://forums.powershell.org/t/function-dynamic-parameter/17302/2 "2021-08-16T21:28:33Z")

</div>

Hi, welcome to the forum 👋

If you’ve searched online for a solution to this I suspect you’ve not yet found what you’re looking for because your search term is wrong 🙂

Rather than dynamic parameters, what you’re looking for is **argument completion**. In PowerShell dynamic parameters is a term used to describe parameters that are only available under certain conditions.

There are several techniques to achieve this - the first link is more to the point, but the second gives a good overview of the different techniques and their limitations.

> **[Creating Dynamic Sets for ValidateSet](https://vexx32.github.io/2018/11/29/Dynamic-ValidateSet/)**
>
> An all too common pattern I see get used in some more advanced scripts is the use of dynamicparam
> where it isn't needed. Unfortunately, dynamicparam can be complicated, quirky, and frustrating to
> work with, and is really best avoided in a majority of...

> **[Argument Completion Attributes - powershell.one](https://powershell.one/powershell-internals/attributes/auto-completion)**
>
> Enable argument completion for your own function parameters and make them so much easier to use! Some lesser-known attributes can help you.

---

<div class="post-metadata">

**Author:** ![dotnVo](https://avatars.discourse-cdn.com/v4/letter/d/4af34b/32.png) [@dotnVo](https://forums.powershell.org/u/dotnVo)\
**Post date:** [May 16, 2024, 8:21pm UTC](https://forums.powershell.org/t/function-dynamic-parameter/17302/3 "2024-05-16T20:21:57Z")

</div>


