I need to pull a list of IDs into a powershell paramater validateset like so:
function Do-Stuff {
[Cmdletbinding()]
param(
[ValidateSet(\"Sea
Alternatively, if you want to use an file to validate against you can use ValidateScript
instead of ValidateSet
like such:
function Do-Stuff {
[Cmdletbinding()]
param(
[ValidateScript({if(([xml](gc c:\temp\config.xml)).getElementsByTagName("City").Name -contains $_){$true}else{throw ([xml](gc c:\temp\config.xml)).getElementsByTagName("City").Name}} )]
[String]$Site
)
That's based on the ridiculously simplistic XML file:
So, anyway, you can use ValidateScript
to run a scriptblock as validation, in which you could load things from an XML file. ValidateSet
on the other hand has to have a pre-defined array of strings to validate against.