PowerShell Dynamic Validate Set
When writing advanced PowerShell functions you may have to add a parameter with a validate set that is created dynamically. Let me use an example to make thing clearer. I was writing a function that has the ability to query different Active Directory forests. That function is actually a wrapper for the Find-LDAPObject cmdlet and provides a better interface by saving the configuration of each directory in a csv file. Each row of the csv file contains the name of the directory, the server and port to connect, the root DN of the directory and the credentials to use. What I wanted to achieve was to create a validate set that would contain all the names of directories in the csv file, so that the user would be able to choose amongst them. Martin Schvartzman has posted a great article on dynamic validate sets that proved to be very helpful! The way to create a dynamic validate set is to create the entire parameter in the function code. We'll start with the standar...