2

When working with powershell cmdlets, I often find that I need to set a switch to a finite number of options, but I don't know what options those are. I end up spending hours trying to google the option that I want. Is there a better way? I've tried looking at microsoft sites and Get-Help -examples, but none of those provide values for the switches that I want.

Here's an example.

Set-SPWebApplication <a couple of switches...> -AuthenticationMethod <String>

What are the acceptable values for -AuthenticationMethod?

This is just one example, but I run into this problem a lot. Im thinking there should be something in the Get-Help that would illuminate me, but that is often unhelpful.

3 Answers 3

6

The easiest way I know is to pass an invalid option and you get a list in the error message:

PS> Set-ExecutionPolicy foo

Set-ExecutionPolicy : Cannot bind parameter 'ExecutionPolicy'. Cannot convert value "foo" to type "Microsoft.PowerShell.ExecutionPolicy" due to invalid enumeration values. Specify one of the following enumeration values and try again. The possible enumeration values are "Unrestricted, RemoteSigned, AllSigned, Restricted, Default, Bypass, Undefined".

At line:1 char:20
+ Set-ExecutionPolicy <<<< foo
    + CategoryInfo : InvalidArgument: (:) [Set-ExecutionPolicy], ParameterBindingException
    + FullyQualifiedErrorId : CannotConvertArgumentNoMessage, Microsoft.PowerShell.Commands.SetExecutionPolicyCommand

At this point you also have the type, so you can also use tab completion to get the valid values:

PS> [Microsoft.PowerShell.ExecutionPolicy]::Tab

Sign up to request clarification or add additional context in comments.

2 Comments

Great, thank you very much. I was hoping microsoft would have provided an easy way to look it up, like with get-help, but this works.
Get-Help is authored by someone, so in many cases the options are listed there and explained. But sometimes they are not, sadly.
1

Can't test with Set-SPWebApplication but:

get-help  out-file -Parameter "encoding"

give an explanation of paramenter and a list of possible value.

Comments

0

You can use this in conjunction with what Christian has suggested

(get-help out-file).syntax ## gives you the sytax

Using Christian's version after that

get-help  out-file -Parameter "encoding"

So, with the 1st one you can look at syntax and then use the second query to go into details of the syntax. You can replace out-file with Set-SPWebApplication.

Hope this helps.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.