PowerShell function parameters using the smart Cue feature example _powershell

Source: Internet
Author: User

This article describes how you can set a function to intelligently prompt for parameter values when customizing the PowerShell function. Smart hints for parameter values This feature is a new feature that appears in PowerShell 3.0.

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.

So, when we're developing a PowerShell function, how do we set the value of our function to intelligently cue parameters in Ise? Take a look at the following example.

Copy Code code as follows:

function Select-color
{
Param
[Validateset (' Red ', ' Green ', ' Blue ')]
$Color
)
"You chose $Color"
}

OK, as you can see, the above function is very simple. The only thing that has not been seen is the phrase [Validateset (' Red ', ' Green ', ' Blue ')], which is used as a set of valid parameter values. And this collection is exactly the optional parameter value that will appear as a smart prompt.

About PowerShell function Intelligent hint parameter value, this article introduces so many, hope to be helpful to you, thank you!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.