Ying Li at myITforum.com

PowerShell & System Center

Get-Command cmdlet in PowerShell

If you play with PowerShell for a while, you probably use get-help and get-member comdlets a lot. Here I want to mention another very handy cmdlet, get-command

In PowerShell console, type get-command | out-file cmdlets.xls

This will create a spreadsheet which contains all the PowerShell cmdlets. As it stands now for CTP 2.0, it has 155 cmdlets.

Let's say you want to use a cmdlet but you don't know the exact verb-noun combination, but you do remember the verb is "export", you can type the below

PS C:\Users\Ying> get-command -verb export

CommandType     Name                                                Definition                                        
-----------     ----                                                ----------                                        
Cmdlet          Export-Alias                                        Export-Alias [-Path] <String> [[-Name] <String[]...
Cmdlet          Export-Clixml                                       Export-Clixml [-Path] <String> [-Depth <Int32>] ...
Cmdlet          Export-Console                                      Export-Console [[-Path] <String>] [-Force] [-NoC...
Cmdlet          Export-Csv                                          Export-Csv [-Path] <String> -InputObject <PSObje...

Similarly, if you know the noun is "object", you can do this:

PS C:\Users\Ying> get-command -noun object

CommandType     Name                                                Definition                                        
-----------     ----                                                ----------                                        
Cmdlet          Compare-Object                                      Compare-Object [-ReferenceObject] <PSObject[]> [...
Cmdlet          ForEach-Object                                      ForEach-Object [-Process] <ScriptBlock[]> [-Inpu...
Cmdlet          Group-Object                                        Group-Object [[-Property] <Object[]>] [-NoElemen...
Cmdlet          Measure-Object                                      Measure-Object [[-Property] <String[]>] [-InputO...
Cmdlet          New-Object                                          New-Object [-TypeName] <String> [[-ArgumentList]...
Cmdlet          Select-Object                                       Select-Object [[-Property] <Object[]>] [-InputOb...
Cmdlet          Sort-Object                                         Sort-Object [[-Property] <Object[]>] [-Descendin...
Cmdlet          Tee-Object                                          Tee-Object [-FilePath] <String> [-InputObject <P...
Cmdlet          Where-Object                                        Where-Object [-FilterScript] <ScriptBlock> [-Inp...

It’s indeed very handy, isn’t it?


 

Posted: Jan 07 2008, 08:12 PM by yli628 | with no comments
Filed under:

Comments

No Comments