I have a parameter property limiting end-user input to specifically allowed values.
I’ve been tasked with using an appropriate method to dynamically create the allowed values based on directory names.
(as a new directory is added the validate set should update, in the code below ‘2005-Std’ is a directory)
I’ve currently hard-coded the allowed inputs:
function install-sql { [CmdletBinding()] param( [Parameter(Mandatory=$True,Position=1,HelpMessage= 'Please enter only the computer name you wish to install SQL to.')] [String]$targetmachine, [Parameter(Mandatory=$True,Position=2,HelpMessage= 'Please enter a SQL Version using the following syntax: YYYY-VER for example: ''2014-ENT'' Proper Versions (VER) are Ent = Enterprise, Dev = Developer, Std = Standard')] [ValidateSet["2005-Std", "2005-Ent", "2008-Std", "2008-Std-R2", "2008-Ent-R2", "2012-Std", "2012-Ent", "2012-Dev-x86", "2012-Dev-x64", "2014-Ent", "2014-Dev"]] [String]$sqlversion, $targetpath, $sqldirectory )
I’ve done quite a bit of research but haven’t found an easy to implement solution.
I appreciate your taking a look at the desired functionality and providing some direction!