Advanced Windows PowerShell Scripting Video Training

Advanced Windows PowerShell Scripting Video Training
Advanced Windows PowerShell Scripting Video Training

Wednesday, January 3, 2018

What is the Difference between Get-Help and Get-Command?

Today I am in Columbus, OH delivering a PowerShell class and this question came up once again.  Well, here are a few examples.

Get-Help obviously gives you access to the help system.  The confusion comes when you do this:
Get-Help Update
Get-Command *Update*

Both yield a list of cmdlets that have Update in their name.  Get-Command has a few extra features to help you filter down that list.  For example:
Get-Command -Verb Update

This will list only cmdlets with the verb Help. This next one only list cmdlets with a noun of Help.

Get-Command -Verb Update

You can also filter through specific modules.
Get-Command -Module SmbShare

You can also use these parameters together to help filter cmdlets
PS C:\> Get-Command -Module SmbShare -verb New

CommandType     Name                                               Version    Source             
-----------     ----                                               -------    ------             
Function        New-SmbMapping                                     2.0.0.0    SmbShare           
Function        New-SmbMultichannelConstraint                      2.0.0.0    SmbShare           
Function        New-SmbShare  

Get-Help will show you a list of all possible matches to a query.  If only one result is returned, it automatically opens the help file for what it has found. For example:
Get-Help Hotfix


You will see the help file for Get-Hotfix.  It is the only cmdlet with Hotfix in the name.

No comments: