Though that is what you can use this for. However, your end goal (allowing wildcard to select any string match) is not an option since that is not unique element in a set.
If you’d try, it will just error out as expected.
myfunc -name 'j*'
myfunc : Cannot validate argument on parameter 'name'. The argument "j*" does not belong to the set "joe,john,dave,dan" specified by the ValidateSet attribute.
Because though you have an [string] ‘array’ defined, you will only get the intelli-sense popup for one element, then you’d have to use the tab key to cycle to get any one of the others.
So, you have to put these names in a collection. Show those names to the user tell then enter a specific name / name set or of part of one, capture that the For Loop to return a result that you can loop to process.
I am going to assume, that list is not a static one, and what you have here is just a sample. So, if you were going to do this using say some sort of list from a file, or a direct call from ADDS, then using a DynamcisParameterSet would be the option.
Dynamic ValidateSet in a Dynamic Parameter
'blogs.technet.microsoft.com/pstips/2014/06/09/dynamic-validateset-in-a-dynamic-parameter'
… though this still is a 1:1 thing.
SO, my suggestion to you is to rethink your use case here. If all you are trying to do is present a list of names for a user to select from. Why do this at the command line at all. Use Out-GridView (which filiterable by the user live), that spits back those selections that your code can act on. The other option is to create your own Datagrid form for the same purpose.
For example:
function Get-TargetUsers
{
[cmdletbinding()]
[Alias('gtu')]
param
(
)
[string[]]$Usernames = ('joe','john','dave','dan' `
| Out-GridView -OutputMode Multiple -Title 'Select a user. Use CTRL+Click to slect multiple users')
foreach ($TargetUser in $Usernames)
{"You selected $TargetUser"}
}
Results
gtu
You selected joe
gtu
You selected dan
You selected joe
gtu
You selected john
You selected dave