help format-list
format-listのヘルプを出力します。
format-list | help
ヘルプのヘルプを出力します(get-help)。
help format-list
format-listのヘルプを出力します。
format-list | help
ヘルプのヘルプを出力します(get-help)。
| または「パイプ」演算子は、ある操作の出力を別の操作にリダイレクトします。したがって、この場合はformat-listを呼び出し、その出力をパラメーターとしてリダイレクトして支援します。ヘルプはそのパラメーターをどう処理するかわからないため、デフォルトの動作になります(ヘルプのヘルプ)。
Help is a function that essentially redirects to:
Get-Help command | more
If you look at this function's definition, you will see that it accepts a positional argument tagged with ValueFromPipelineByPropertyName
with an argument of Name
.
PS ~\> Get-Content function:help
<#
.FORWARDHELPTARGETNAME Get-Help
.FORWARDHELPCATEGORY Cmdlet
#>
[CmdletBinding(DefaultParameterSetName='AllUsersView')]
param(
[Parameter(Position=0, ValueFromPipelineByPropertyName=$true)]
[System.String]
${Name},
# Other arguments deleted for brevity
[Switch]
${Online})
$outputEncoding=[System.Console]::OutputEncoding
Get-Help @PSBoundParameters | more
This basically means, if it sees an argument with a property called Name
, it binds that as an input parameter. So, when you do:
format-list | help
the format-list command is run (and nothing is returned), so the help function thinks it received no arguments.
When you do:
"format-list" | help
You are passing a string argument. The string type does not have a Name
prooperty, so you'll get an error message saying that it can't bind the arguments. However, if you tried:
PS ~\> get-command format-list
CommandType Name Definition
----------- ---- ----------
Cmdlet Format-List Format-List [[-Property] <Object[]>] [-GroupBy <...
you can see the the command format-list does have a Name property, so if you tried
get-command format-list | help
You get the help for format-list
.