Return to site

Supply values for the following parameters

broken image

When you've written a function or script with a parameter, this parameter can be made to require a value before the script runs known as mandatory. Related: Building PowerShell Scripts To Tie Disparate Products Together Inputting Mandatory Parameters There are a few ways to interactively prompt a user for input which we'll discuss. To provide input a script or function, we can use another way known as interactive prompting. However, the user must remember to use parameters and parameters cannot be used once inside of a script or function. By providing parameter input, the user can insert his/her own values into the code without actually changing anyway. It's always a good idea to separate out these 'questions' from your code logic in the form of parameters.

broken image

Unless you provide instructions for what you need to be done in your script, PowerShell's not going to know if you meant file path A, file path B, a virtual machine named DC or if you want to really shut down an entire data center.

broken image
broken image

PowerShell is a powerful scripting language that can get a lot done, but it's not telepathic. In this PowerShell tutorial, we will cover a few ways to interactively prompt a user for input.