Tuesday, 9 September 2014

Help Vs Get-Help In PowerShell

At the first look there is no difference between help and get-help. But they are entirely different command.. I am giving some examples to understand about help and get-help

001
002
003
004
005
006
007
008
009
Get-Command *help*

CommandType     Name                            ModuleName
-----------     ----                            ----------
Function        help                                      
Cmdlet          Get-Help                        Microsoft.PowerShell.Core
Cmdlet          Save-Help                       Microsoft.PowerShell.Core
Cmdlet          Update-Help                     Microsoft.PowerShell.Core
Application     help.exe

From the above example, you will be able to understand the Command types of help and get-help
Help is a function and Get-help is a Cmdlet... And there is no Alias for get-help. Man is the alias for help. Please go through the below examples..

001
002
003
004
005
006
007
008
009
010
011
012
013
014
015
Get-Alias -Definition Help

CommandType     Name                                               ModuleName
-----------     ----                                               ----------
Alias           man -> help                                                  

Get-Alias -Definition Get-Help

Get-Alias : This command cannot find a matching alias because an alias with the definition 'Get-Help' does not exist.
At line:1 char:1
+ Get-Alias -Definition Get-Help
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (Get-Help:String[Get-Alias], ItemNotFoundException
    + FullyQualifiedErrorId : ItemNotFoundException,Microsoft.PowerShell.Commands.GetAliasCommand

Type Get-Content function:\help If you want to see the content inside the function.

No comments:

Post a Comment