Getting Help
The most important PowerShell command to learn first is the one that helps you learn about the others! It’s called get-help
, but it has a predefined alias named help
, so you can use either of these command names interchangeably. PowerShell has a lot of built-in help—477 different topics, in fact, at the time I wrote this.
Here are some tips:
- Type the word
help
by itself to get a quick introduction to the online help system. - After
help
orget-help
, you can type a word, cmdlet name, or partial cmdlet name. You can also type a phrase enclosed in quotation marks. If more than one topic, cmdlet name, or description matches what you typed,get-help
prints a list of all matching help entries. You can then typehelp
followed by the specific entry name that interests you to get the details. If exactly one name or description contains the word or phrase you typed,get-help
prints the help information for that topic. - Some cmdlets have additional help information available. For example, you can see some examples of using the
new-alias
cmdlet by typinghelp new-alias -examples
. Common options for additional information are-examples
, -detailed
, and-full
. The main help page for a topic tells you whether these expanded pages are available. - The help text appears in the console window and by default is piped through
more
so it stops after every screenful. Press Enter to go on to the next page. - Alternatively, you might find it easier to direct help output into a file by adding, for example,
>x
to the end of the help command line; then, typenotepad x
to read the text. - There are help entries covering every one of the installed cmdlets and additional articles on different topics. These articles start with
about_
. For example,help about_execution_policies
prints information about the scripting security restriction system. (You can also typehelp about_exec
and get the same result because only one entry contains the string “about_exec” in its title or description.) To see a list of all of these “about” entries, typehelp about
.
This online help system is great for locating cmdlets based on words in the description of the job they do and for learning about their command-line syntax after you’ve found a cmdlet that interests you.
Tip - In the online syntax descriptions, the following conventions are used:
[ ] square brackets indicate optional command arguments.
{ } curly braces usually indicate a series of options from which you can choose, with a vertical bar
|
between the options.< > angle brackets surround a value that you have to supply yourself. For example,
[-Description <string>]
indicates an optional argument. You can omit it, or you could type something like-description “some text”
. As I mentioned in the previous section, you could probably abbreviate this to-descr “some text”
.
Prompting to Complete Commands
If you type a PowerShell command that requires specific arguments, but omit some or all of the required arguments, PowerShell prompts for them by name. Here’s an example: If you type set-alias
without any arguments, PowerShell prompts for the required -name
and -value
arguments. Here’s how it looks:
PS C:\Users\bknittel> set-alias <br> <strong>cmdlet Set-Alias at command pipeline position 1</strong> <br> Supply values for the following parameters: <br> Name: <em>ax</em> <br> Value: <em>get-alias</em>
(I typed the responses in italics.) This mechanism can help you as you learn to use the cmdlets, but remember that PowerShell won’t prompt for optional arguments, just the required ones.
Personally, I don’t find this mechanism that useful and never trigger it deliberately. You should know it exists though because if you omit a required argument from a command, PowerShell might prompt you in this way and you might find it confusing at first.