Dynamic Parameters - with Dynamic ValidateSet Dynamic Parameters - with Dynamic ValidateSet powershell powershell

Dynamic Parameters - with Dynamic ValidateSet


The problem is that you have all the dynamic logic inside scriptblock in the if statement, and it handles the parameter addition only if the path provided contains a semicolon (':'). You could change it to something like:

if($path.ToCharArray() -contains ':') {    $FilePath = "\\$ComputerName\$($path -replace ':','$')"} else {    $FilePath = $path}

and continue your code from there