
However, know that this isn’t the only way to create a parameter. In this tutorial, I’ll show you the “best” way to create parameters based on my nearly decade of experience with PowerShell. Now what? You now can add one, but like any great programming language, there are multiple ways to skin that cat. So you know you need a Version parameter. As long as you answer that question as precisely as possible, it will always help. But, when you’ve got a function with tens of lines of code, the answer won’t be too apparent. In this example, the parameter is probably clear to you you need to add a Version parameter. Remember that you need to rerun this function without changing any of the code inside of the function. Since we’d like to install different versions of Office without changing the code every time, you have to add at least one parameter to this function.īefore you quickly think up a PowerShell parameter to use, it’s essential first to ask yourself a question “What is the smallest change or changes you expect will be needed in this function?”. Yep! Parameters or what some people call arguments.


Instead, you need a way to pass in different values at runtime to change the function’s behavior. You’re going to have to duplicate lots of code when you don’t have to. It forces you to create a separate function for every single version of Office that comes out. Yippee!'ĭoing this works, but it’s not scalable.
