Getting Detailed Help Information
Windows PowerShell has detailed help documentation for all cmdlets. To display the help topics, use the Get-Help cmdlet. For example, to get help for the Get-Childitem cmdlet, type:
get-help get-childitem
or
get-childitem -?
You can also display one page of each help topic at a time by using the man and help functions. To use them, type man or help followed by the cmdlet name. For example, to display help for the Get-Childitem cmdlet, type
man get-childitem
or
help get-childitem
The Get-Help cmdlet also displays information about conceptual topics in Windows PowerShell. Conceptual help topics begin with the "about_" prefix, such as about_line_editing. (The name of the conceptual topic must be entered in English even on non-English versions of Windows PowerShell.)
To display a list of conceptual topics, type:
get-help about_*
To display a particular help topic, type the topic name, for example:
get-help about_line_editing
Using Familiar Command Names
Using a mechanism called aliasing, Windows PowerShell allows users to refer to commands by alternate names. Aliasing allows users with experience in other shells to reuse common command names that they already know to perform similar operations in Windows PowerShell. Although we will not discuss Windows PowerShell aliases in detail, you can still use them as you get started with Windows PowerShell.
Aliasing associates a command name that you type with another command. For example, Windows PowerShell has an internal function named Clear-Host that clears the output window. If you type either the cls or clear command at a command prompt, Windows PowerShell interprets that this is an alias for the Clear-Host function and runs the Clear-Host function.
This feature helps users to learn Windows PowerShell. First, most Cmd.exe and UNIX users have a large repertoire of commands that users already know by name, and although the Windows PowerShell equivalents may not produce identical results, they are close enough in form that users can use them to do work without having to first memorize the Windows PowerShell names. Second, the major source of frustration in learning a new shell when the user is already familiar with another shell, is the errors that are caused by "finger memory". If you have used Cmd.exe for years, when you have a screen full of output and want to clean it up, you would reflexively type the cls command and press the ENTER key. Without the alias to the Clear-Host function in Windows PowerShell, you would simply get the error message "'cls' is not recognized as a cmdlet, function, operable program, or script file." and be left with no idea of what to do to clear the output.
The following is a brief listing of the common Cmd.exe and UNIX commands that you can use inside Windows PowerShell:
| cat | dir | mount | rm |
| cd | echo | move | rmdir |
| chdir | erase | popd | sleep |
| clear | h | ps | sort |
| cls | history | pushd | tee |
| copy | kill | pwd | type |
| del | lp | r | write |
| diff | ls | ren |
If you find yourself using one of these commands reflexively and want to learn the real name of the native Windows PowerShell command, you can use the Get-Alias command:
PS> Get-Alias cls
CommandType Name Definition
----------- ---- ----------
Alias cls Clear-Host
To make examples more readable, the Windows PowerShell Primer generally avoids using aliases. However, knowing more about aliases this early can still be useful if you are working with arbitrary snippets of Windows PowerShell code from another source or wish to define your own aliases. The rest of this section will discuss standard aliases and how to define your own aliases.
Posted in: Software| Tags: PowerShell Information Childitem get-childitem man Get Sleep Write rm rmdir echo cat dirDisplaying available command types
The Get-Command command does not list every command that is available in Windows PowerShell. Instead, the Get-Command command lists only the cmdlets in the current shell. Windows PowerShell actually supports several other types of commands. Aliases, functions, and scripts are also Windows PowerShell commands, although they are not discussed in detail in the Windows PowerShell Primer. External files that are executables, or have a registered file type handler, are also classified as commands.
You can return a listing of all items that can be invoked by entering the following command:
PS> Get-Command *
Because this list includes external files in your search path, it may contain thousands of items. It is more useful to look at a reduced set of commands. To find native commands of other types, you can use the CommandType parameter of the Get-Command cmdlet. Although we have not talked about these other command types yet, you can still display them if you know the name of the CommandType for a class of commands.
Note:
Although we have not discussed it yet, the asterisk (*) is used for wildcard matching in Windows PowerShell command arguments. The * means "match one or more of any characters". You can type Get-Command a* to find all commands that begin with the letter "a". Unlike wildcard matching in Cmd.exe, Windows PowerShell's wildcard will also match a period.
To display the special command category aliases (these are nicknames used as alternatives to standard command names), enter the following command:
PS> Get-Command -CommandType Alias
To display all Windows PowerShell functions, enter the following command:
PS> Get-Command -CommandType Function
To display external scripts in Windows PowerShell's search path, enter the following command:
PS> Get-Command -CommandType ExternalScript
Posted in: Software| Tags: Windows PowerShell Command Display Get external displaying primer detail aliases shellGetting Summary Command Information
The Windows PowerShell Get-Command cmdlet retrieves the names of all available commands. When you type Get-Command at a Windows PowerShell prompt, you will see output similar to the following:
PS> Get-Command
CommandType Name Definition
----------- ---- ----------
Cmdlet Add-Content Add-Content [-Path] <String[...
Cmdlet Add-History Add-History [[-InputObject] ...
Cmdlet Add-Member Add-Member [-MemberType] <PS...
...
This output looks a lot like the Help output of Cmd.exe: a tabular summary of internal commands. In the extract of the Get-Command command output shown above, every command shown has a CommandType of Cmdlet. A Cmdlet is Windows PowerShell's intrinsic command type that corresponds roughly to the dir and cd commands of Cmd.exe and to built-ins in UNIX shells such as BASH.
In the output of the Get-Command command, all of the definitions end with ellipses (...) to indicate that PowerShell cannot display all of the content in the available space. When Windows PowerShell displays output, it formats the output as text and then arranges it to make the data fit cleanly into the window. We will talk about this later in the section on formatters.
The Get-Command cmdlet has a Syntax parameter that allows you to retrieve just the syntax of each cmdlet. Enter the Get-Command -Syntax command to display the full output:
PS> Get-Command -Syntax
Add-Content [-Path] <String[]> [-Value] <Object[]> [-PassThru] [-Filter <String>] [-Include <String[]>] [-Exclude <String[]>] [-Force] [Credential <PSCredential>] [-Verbose] [-Debug] [-ErrorAction <ActionPreference>] [-ErrorVariable <String>] [-OutVariable <String>] [-OutBuffer <Int32>] [-WhatIf] [-Confirm] [-Encoding <FileSystemCmdletProviderEncoding>]
Add-History [[-InputObject] <PSObject[]>] [-Passthru] [-Verbose] [-Debug] [-ErrorAction <ActionPreference>] [-ErrorVariable <String>] [-OutVariable <String>][-OutBuffer <Int32>]...
Posted in: Software| Tags: Windows Type PowerShell Command Information Get summary cmdlet output