Author Posts

December 4, 2017 at 5:22 pm

Hi,

I've created an advanced function which has a few parameters that required the ValidateSet to be dynamically populated.
Is there a way to auto populate the set from another cmdlet?

Thanks

Tommy.

December 4, 2017 at 5:24 pm

Kind of. What you're looking for is a Dynamic Parameter. Check out https://blogs.technet.microsoft.com/pstips/2014/06/09/dynamic-validateset-in-a-dynamic-parameter/. Alternately, you could write a ValidateScript instead, but that's not going to provide tab completion for permitted values.