I’m trying to build a PowerShell script that has a parameter validated from a SQL table. It performs validation, but does not have tab completion from the list. Is it possible to have this do list validation and tab completion? The contents of the list in the SQL table can change over time, so I cannot hard code the parameter list into the script.
Here’s the code I’m trying to use to make sure the value for the parameter LoginID exists in the SQL table. Again, the validation works, but there is no tab completion. So if I don’t know the LoginID, I have to look it up elsewhere before I run the script instead of tab completion helping me out.
Param (
[parameter()]
[ValidateScript({$_ -in ((Invoke-Sqlcmd -ServerInstance SQLServer -Database DB1 -Query “Select * from LookupTable”).LoginID)})]
[string]
$LoginID
)