Creating Aliases
Windows PowerShell includes many built-in aliases,
but you can also create your own. The following table shows you how to
list the aliases and create your own.
Command | Comments |
---|
| Provides a listing of all aliases. It includes built-in aliases and user-defined aliases. This returns the same data as get-alias and get-command -commandtype alias. |
set-alias alias command PS C:\> set-alias gh get-help
| Creates or changes an alias.
The example creates an alias named gh that can be entered instead of the command get-help. |
Discovering Windows PowerShell Commands
Few people will master all of the PowerShell
commands; however, you can master a basic self-discovery method used to
learn and master any specific command. This method includes three
important commands, as described in the following table.
PowerShell Discovery Commands | Comments |
---|
get-command [switches] PS C:\> get-command PS C:\> get-command -commandtype cmdlet PS C:\> get-command -commandtype alias PS C:\> get-command -commandtype function
| The get-command cmdlet shows all of the possible commands.
You can list the cmdlets, aliases, or functions separately as shown by the three examples. |
get-help get-help command [-full | -detailed | -examples] PS C:\> get-help set-executionpolicy -full PS C:\> get-help get-process -detailed PS C:\> get-help start-service -examples
| The get-help command provides access to a rich set of built-in help.
You can follow get-help with the name of any command. By default, it provides basic help. However, you can also add the -full, -detailed, or -examples switches.
The -detailed switch expands the basic information with more details and includes examples.
The -full switch
provides verbose help, including technical information. It includes all
available help information including examples. It often includes online
links for more information.
The -examples switch shows a brief synopsis with examples. |
get-member command or object | get-member PS C:\> get-service | get-member
$variable| get-member PS C:\> $profile | get-member
| The get-member
command provides information about properties and methods you can use
with the command. Almost all of the commands are objects, meaning they
have properties and methods.
Properties are descriptions that you can retrieve and sometimes
configure. Methods are actions you can take with the item. |
There are also many help topics available on
conceptual PowerShell topics. These are called “about” topics and they
all start with about_.
List all about topics.
| The * (asterisk) wildcard can be used to list all about topics (all topics that start with about_). |
View any specific about topic.
get-help about_topic PS C:\> get-help about_execution_policies
| You can then use the get-help command to view the about_topic. |