| Written by Diana, on 04-09-2007 01:16 |
| Views |
66  |
|
|
|
PS C:\Users\Admin> help gcm -full
NAME Get-Command
SYNOPSIS Gets basic information about cmdlets and about other elements of Windows PowerShell commands.
SYNTAX Get-Command [[-argumentList] <Object[]>] [-verb <string[]>] [-noun <string[]>] [-totalCount <int>] [-syntax] [-pSSnapIn <string[]>] [<CommonParameters>]
Get-Command [[-name] <string[]>] [[-argumentList] <Object[]>] [-commandType {<Alias> | <Function> | <Filter> | <Cmdlet> | <ExternalScript> | <Application> | <Script> | <All>}] [-totalCount <int>] [-syntax] [<CommonParameters>]
DETAILED DESCRIPTION The Get-Command cmdlet gets basic information about cmdlets and other elements of Windows PowerShell commands, such as files, functions, and Windows PowerShell providers.
PARAMETERS -name <string[]> Gets information only about the cmdlets or command elements with the specified name. <String> represents all or part of the name of the cmdlet or command element. Wildcards are permitted.
Required? false Position? 1 Default value Accept pipeline input? true (ByValue, ByPropertyName) Accept wildcard characters? true
-verb <string[]> Gets information about cmdlets with names that include the specified verb. <String> represents one or more verbs or verb patterns, such as "remove" or *et". Wildcards are permitted.
Required? false Position? named Default value Null Accept pipeline input? true (ByPropertyName) Accept wildcard characters? true
-noun <string[]> Gets cmdlets with names that include the specified noun. <String> represents one or more nouns or noun patterns, such as "process" or "*item*". Wildcards are permitted.
Required? false Position? named Default value Null Accept pipeline input? true (ByPropertyName) Accept wildcard characters? true
-commandType <CommandTypes> Gets only the specified types of command objects. Valid values for <CommandTypes> are: Alias ExternalScript All Filter Application Function Cmdlet (default) Script
"Application" represents all non-PowerShell files on the system that you can run within PowerShell, including .txt, .exe. and .dll files in the Windows PowerShell path.
"Filter" and "Function" represent all Windows PowerShell functions.
You can use CommandType or its alias, Type. The following lists the acceptable values for this parameter:
Alias
Function
Filter
Cmdlet
ExternalScript
Application
Script
All
Required? false Position? named Default value Cmdlet Accept pipeline input? true (ByPropertyName) Accept wildcard characters? false
-totalCount <int> Determines how many command elements Windows PowerShell retrieves.
Required? false Position? named Default value -1 (all) Accept pipeline input? true (ByPropertyName) Accept wildcard characters? false
-syntax <SwitchParameter> Gets only specified data about the command element. * For aliases, retrieves the standard name. * For cmdlets, retrieves the syntax. * For functions and filters, retrieves the function definition. * For scripts and applications (files), retrieves the path and filename.
Required? false Position? named Default value False Accept pipeline input? true (ByPropertyName) Accept wildcard characters? false
-argumentList <Object[]> Gets information about a cmdlet when it is used with the specified parameters ("arguments"), such as a path. To detect parameters that are added to a cmdlet dynamically, replace <Object[]> with parameters that are specific to a Windows PowerShell provider or cmdlet, for example, "HKML\Software" or "cert:\my".
Required? false Position? 2 Default value Accept pipeline input? false Accept wildcard characters? false
-pSSnapIn <string[]> Get the cmdlets supported by the specified Windows PowerShell snap-in. For more information, type "get-help about-PSSnapins".
Required? false Position? named Default value unspecified Accept pipeline input? true (ByPropertyName) Accept wildcard characters? true
<CommonParameters> This cmdlet supports the common parameters: -Verbose, -Debug, -ErrorAction, -ErrorVariable, and -OutVariable. For more information, type, "get-help about_commonparameters".
INPUT TYPE String
RETURN TYPE Object
NOTES
For more information, type "Get-Help Get-Command -detailed". For technical information, type "Get-Help Get-Command -full".
Without parameters, "Get-Command" gets information about the Windows PowerShell cmdlets. Use the parameters to qualify the elements retrieved.
By default, Get-Command returns elements in the order that it discovers them. The discovery order is also the order in which the items are run when a run command is ambiguous. For example, if the discovery order of items is notepad.exe, notepad.cmd, and notepad.ps1, and you run "Notepad," the system runs Notepad.exe. The discovery order often provides valuable information. If you need to have the data in a different order, use the Sort-Object cmdlet to sort it.
When specifying multiple values for a parameter, use commas to separate the values. For example, "<parameter-name> <value1>, <value2>".
You can also refer to Get-Command by its built-in alias, "gcm". For more information, see About_Alias.
----------------- EXAMPLE 1 -----------------
C:\PS>get-command
This command retrieves information about all of the Windows PowerShell cmdlets. The default display lists the command type ("Cmdlet"), the name of the cmdlet, and the syntax.
----------------- EXAMPLE 2 -----------------
C:\PS>get-command -verb set | format-list
This command retrieves information about all of the cmdlets with the verb "set," and displays some of that information in a list. The list format includes fields that are omitted from the table display, including the complete syntax. To display all fields (all properties of the object), type "get-command -verb set | format list *".
----------------- EXAMPLE 3 -----------------
C:\PS>get-command | sort-object noun | format-table -group noun
This command retrieves all of the cmdlets, sorts them alphabetically by the noun in the cmdlet name, and then displays them in noun-based groups. This display can help you find the cmdlets for a task.
By default, Get-Command displays items in the order in which the system discovers them, which is also the order in which they are selected to run when a run command is ambiguous.
----------------- EXAMPLE 4 -----------------
C:\PS>get-command -pssnapin Microsoft.PowerShell.Security
This command retrieves information about the cmdlets in the Microsoft.PowerShell.Security PSSnapin.
----------------- EXAMPLE 5 -----------------
C:\PS>get-command get-childitem -ArgumentList cert: | format-list
This command retrieves information about the Get-Childitem cmdlet when Get-Childitem is used with the Windows PowerShell Certificate provider. When you compare the syntax displayed in the output with the syntax that is displayed when you omit the ArgumentList parameter, you'll see that the Certificate provider dynamically adds a parameter, CodeSigningCert, to the Get-Childitem cmdlet.
----------------- EXAMPLE 6 -----------------
C:\PS>(get-command get-childitem -ArgumentList cert:).parametersets[0].parameters | where-object { $_.IsDynamic }
This command retrieves only parameters that are added to the Get-Childitem cmdlet dynamically when it is used with the Windows PowerShell Certificate provider. This is an alternative to the method used in the previous example.
In this command, the "get-command get-childitem -ArgumentList cert:" is processed first. It requests information from Get-Command about the Get-Childitem cmdlet when it is used with the Certificate provider. The ".parametersets[0]" selects the first parameter set (set 0) of "get-childitem -argumentList cert:" and ".parameters" selects the parameters in that parameter set. The resulting parameters are piped to the Where-Object cmdlet to test each parameter ("$_.") by using the IsDynamic property. To find the properties of the objects in a command, use Get-Member.
----------------- EXAMPLE 7 -----------------
C:\PS>get-command *
This command retrieves information about all of the elements available to Windows PowerShell, including files, functions, aliases, and cmdlets.
RELATED LINKS Get-Help Get-PSDrive Get-Member
Last update: 04-09-2007 01:16
Users' Comments (0)
|
|
|