≡ Menu

Using Parametersets in PowerShell

Parameter sets in PowerShell allows grouping of parameters so that availability of parameters is controlled based on what is already specified and at what position. Great way to write proper production scripts. They are available from PowerShell V2 onward.

I found couple of useful posts on this topic which are giving good explanation of this approach with some easy examples. It is important to understand them property before try in your scripts. Otherwise you will end up removing them from code due to frustration. That means you are loosing great power in validating the arguments.

Below are the two articles I found useful to understand parameter sets.

http://blog.powershell.no/2012/07/02/how-to-configure-a-function-parameter-to-belong-to-multiple-parameter-sets/

http://blogs.msdn.com/b/powershell/archive/2008/12/23/powershell-v2-parametersets.aspx

Happy learning…