3

PowerShell: Get Command Help (–help/-h/?) [SOLVED]

 8 months ago
source link: https://www.shellhacks.com/powershell-get-command-help-help-h-solved/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

PowerShell: Get Command Help (–help/-h/?) [SOLVED]

The help command is a special command that is used to provide more information on another commands.

In Windows PowerShell the help command can be called at any time to learn more about a command’s usage and syntax, like the available options and how to structure the command to use these options.

However, at first, it may not be so obvious how to actually call the help command in PowerShell and this short post can help you with this.

Get Command Help in PowerShell

If you try to get a command help in PowerShell in a common way, neither of --help, -h, /h or even /? options may work:

PS C:\> Get-Content --help
PS C:\> Get-Content -h
PS C:\> Get-Content /h
PS C:\> Get-Content /?
- sample output -
Get-Content : Cannot find path 'C:\Users\Username\--help' because it does not exist.
At line:1 char:1
+ Get-Content --help
+ ~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (C:\Users\Username\--help:String) [Get-Content], ItemNotFoundException
    + FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.GetContentCommand

The proper way of getting the command help in PowerShell is by using the Get-Help command or its help alias as follows:

PS C:\> help Get-Content
- or -
PS C:\> Get-Help Get-Content
- sample output -
NAME
    Get-Content

SYNTAX
    Get-Content [-Path]  [-ReadCount ] ...
[]>

😀 Now you know how to get help in PowerShell!

The trick is simple – just put the Get-Help or help in front of the command which usage or syntax you need to know.

Was it useful? Share this post with the world!

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK