PowerShell Basics (ii)

Source: Internet
Author: User
Tags aliases

The previous section focuses on features such as PowerShell discovery, object-oriented, consistency, and PowerShell commands are based on important concepts such as. NET objects, as well as the naming conventions for PowerShell commands, click here for details.


The PowerShell basics in this section mainly include the following knowledge points

    1. Gets the summary information for the command.

    2. Gets the help information for the command.

    3. Summarize.

Get summary information for a command

PowerShell command  Get-Command  to retrieve all the available command names in the current shell. Enter  GET-COMMAND&NBSP at the PowerShell prompt, and the output is similar to the following (only some of the output results are written below).

ps c:\documents and settings\administrator> get-commandcommandtype      Name                                                   Definition-----------     ----                                                   ----------alias           %                                                      ForEach-ObjectAlias            ?                                                      where-objectfunction        a:                                                     Set-Location A:Alias            ac                                                    Add-ContentCmdlet           Add-Computer                                          add-computer [- Domainname] <string> [-credential ... cmdlet          add-content                                       &nbSp;   add-content [-path] <string[]> [-value] <object[... cmdlet          add-history                                            Add-history [[-inputobject] <psobject[]>] [-pass ... cmdlet          add-member                                             add-member [-membertype] <psmembertypes> [-name] ...

In the output of the Get-command command, all definitions end with ellipses (...), indicating that PowerShell is unable to display all content within the available space. When the output is displayed, PowerShell formats the output as text and then arranges it so that the data is displayed neatly in the window. The formatting of the command output is described in detail in subsequent articles.

The Get-command cmdlet has a Syntax parameter that you can use to retrieve only the syntax for each cmdlet . Enter the Get-command-syntax command to display the full output:

ps c:\documents and settings\administrator> get-command - syntaxforeach-objectwhere-objecta:add-contentadd-computer [-domainname] <string> [- credential <pscredential>] [-oupath <string>] [-passthru] [-server  <string>] [-unsecure] [-verbose] [-debug] [-erroraction <actionpreference >] [-warningaction <actionpreference>] [-errorvariable <string>] [- Warningvariable <string>] [-outvariable <string>] [-outbuffer <int32 >] [-whatif] [-confirm]add-computer [-workgroupname] <string> [-credential  <PSCredential>] [-PassThru] [-Verbose] [-Debug] [-ErrorAction < Actionpreference>] [-warningaction <actionpreference>] [-errorvariable <string >] [-warningvariable <string>] [-outvariable<string>] [-outbuffer <int32>] [-whatif] [-confirm]add-content [ -path] <string[]> [-value] <object[]> [-passthru] [-filter < string>] [-include <string[]>] [-exclude <string[]>] [-force] [- credential <pscredential>] [-verbose] [-debug] [-erroraction < Actionpreference>] [-warningaction <actionpreference>] [-errorvariable <string >] [-warningvariable <string>] [-outvariable <string>] [-outbuffer  <Int32>] [-WhatIf] [-Confirm] [-UseTransaction] [-Encoding < filesystemcmdletproviderencoding>]add-content [-literalpath] <string[]> [-value]  <object[]> [-passthru] [-filter <string>] [-include <string[]>]  [-exclude <string[]>] [-force] [-credential <pscredential>] [-verbose] [-debug] [-erroraction < Actionpreference>] [-warningaction <actionpreference>] [-errorvariable <string >] [-warningvariable <string>] [-outvariable <string>] [-outbuffer  <Int32>] [-WhatIf] [-Confirm] [-UseTransaction] [-Encoding < Filesystemcmdletproviderencoding>]

It is important to note that theget-command command lists only the cmdlets in the current shell, not all the available commands in PowerShell . aliases, functions, and scripts are also PowerShell commands, and external programs are also categorized with commands. You can return a list of all callable items by entering the following command:

Ps> Get-command *

Because this list includes external files in the search path, it may contain thousands of items. In fact, it is more useful to view only the reduced set of commands. To find other types of native commands, you can use the CommandType parameter of the Get-command cmdlet. Although we have not yet covered these other command types, you can still display these command types if you know the CommandType name of a certain type of command.

Note : the asterisk (*) in the command is a wildcard character, which means "match one or more arbitrary characters", such as input Get-command *ervice* lists all commands that contain "Ervice".

To display aliases for special command categories (alternative names for standard command names), you can 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 the PowerShell search path, enter the following command:

Ps> Get-command-commandtype Externalscript

Get help information for a command

    • Get cmdlet Help information

To get help with PowerShell cmdlets, use the Get-help cmdlet. For example, to get help for Get-childitem, enter:

Get-help Get-childitem

Or

Get-childitem-?

Of course, you can get help with the GET-HELP command itself, for example:

Get-help Get-help

To get a list of all the cmdlet Help topics in a session, type:

Get-help-category cmdlet

To display a page for each Help topic each time, use the helper function or its alias, man. For example, to display Help for the Get-childitem cmdlet, type

Mans Get-childitem

Or

Help Get-childitem

To display detailed information about a cmdlet, function, or script, including its parameter descriptions and usage examples, use the detailed parameter of the Get-help cmdlet. For example, to get more information about the Get-childitem cmdlet, type:

Get-help get-childitem-detailed #显示get-childitem For more information get-help get-childitem-full #显示get-childitem Help topics all content get-help Get-childitem-parameter * #显示get The-childitem parameter for more help Get-help get-childitem-examples #显示get0childitem的帮助中的示例

Note : In PowerShell, #用于注释, similar to "///" in Java or C #.

    • Get conceptual help. PowerShell gets conceptual help through the Get-help about_* command.

    • Get Help on a provider

      PowerShell can get help information for the provider. To obtain help for the registry provider, enter:

Get-help Registry

To get a list of all the provider Help topics in your session, enter

Get-help-category Provider

The various parameters of get-help, such as detailed, Parameter, and Examples, have no effect on the display of the provider's Help topics.

    • Get networking Help

      If your computer is already connected to the network, the best way to see Help is to check the online Help topic, which makes it easier to provide the latest content.

To use the Online parameter of the Get-help cmdlet, use the following command format.

Get-help <command-name>-online

If the command provides an online version of the Help topic, it will open in the default browser.

Summarize

By studying this section, you should be familiar with the following content.

    1. You can view all the commands available in the current shell and all the available commands in PowerShell.

    2. For any command, it will view its summary information, syntax information, and the retrieval of the specified type command.

    3. You can get help information for the specified command, including online help information.

    4. Know that "#" in PowerShell is a comment for the content.


This article from "Flower Blossom Fall" blog, declined reprint!

PowerShell Basics (ii)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.