Get to know Parameter Sets

by Feb 18, 2010

Sometimes, you may run into issues like this once you learned more about the parameters a given cmdlet supports:

Get-Random -Minimum 1 -Maximum 50 -Count 7

Although all three parameters are valid, you will get an exception because cmdlets can separate parameters into parameter sets. But you can only use parameters of one set so you will get an exception once you try and mix parameters of different sets.

For example, the parameter sets that a cmdlet supports are listed by Get-Help:

Get-Help Get-Random

Take a look at the SYNTAX section. When you see more than one syntax, you can know that each one represents a separate parameter set. As it turns out, you cannot mix -minimum and -maximum with -count.

Twitter This Tip! ReTweet this Tip!