This article describes how you can set a function to use an enumeration variable to intelligently cue parameter values when customizing the PowerShell function. The enumeration type can be. NET Framework, the system enumeration type.
In the PowerShell 3.0 version, a new feature appears, which is the smart hint for parameter values. Of course, it's not just anywhere. Smart Cue parameter values, but only in Ise. Of course, the so-called ISE is an integrated development environment with PowerShell.
This article describes the use of the system's own enumerated variables as an enumeration option for smart hints.
Let's take a look at the Select-color again.
Copy Code code as follows:
function Select-color
{
Param
[Validateset (' Red ', ' Green ', ' Blue ')]
$Color
)
"You chose $Color"
}
Here is a list of smart hints using Valiateset as a parameter value, and we can modify it to use an enumeration type as a smart hint list for parameter values.
Copy Code code as follows:
function Select-color
{
Param
[System.consolecolor]
$Color
)
"You chose $Color"
}
OK, as you can see, the changes are simple, and the set of valid values [Validateset (' Red ', ' Green ', ' Blue ')] is changed to the system's own enumeration type [System.consolecolor], which also enables you to implement smart hints for parameter values.
About the PowerShell function to use enumerated variables as a parameter smart hint, this article on the introduction of so many, I hope to help you, thank you!