Argument Completer or validateset in scriptmethod add-member object

A tricky one…

I have a function that builds and array of all supported resolutions on a machine using WMI classes : It Works
I use that code in two other functions,
One uses a dynamic parameter with a validateset built using the first function code It Works
The other uses the same code to build an argument completer for a parameter It also works.

Now , I creates a pscustomobject, adds two noteproperties : name and resolution It works.

NOW , THE PROBLEM ….

Of course I can set name and resolution properties of my pscusomobject using $Custobj.name = “oooo” and $Custobj.resolution = “thisresolution”

Now, If I create a scriptmethod like this :

Changeresolution =
{
Param
(
$NewResolution
)

$this.resolution = $Newresolution

}

IT WORKS BUT DOES NOTHING MORE…
I COULD NOT FOUND HOW TO BE ABLE TO USE THE CHANGERESOLUTION METHOD AND HAVE THE POSSIBLE VALUE PROPOSED. Any idea ???

From what I can gather the option you are looking for is “Validateset()” like this:-

Function set-resolution {
    param (
        [validateset(1,2,3,4)]
        $newresolutuion
    )
    
    "new resolution is {0}" -f $newresolutuion
}

and if you type :

set-resolution -newresolutuion 

and press tab it goes through the specified list 1,2,3,4 etc…

however I can’t see a way of appling this to Scriptproperties or Scriptmethods

I have even looked into class definitions and they also don’t support the validateset() option either.

So my advise would be to add a function that emunerates the valid options and then add to the Changeresolution method a way of validating the input against the same list.

I’m sorry thats not much help,

If anyone knows a way to apply this to script methods I would also be interested.