使用参数-online为`man`创建别名?

nin*_*key 4 powershell

我想为其创建一个别名Get-Help [foo] -online.但我无法得到有关工作的论据.

我试了几件事,包括 Set-Alias -Name mano -Value "Get-Help -online"

PS C:\Program Files\ConEmu> mano Get-Content
Cannot resolve alias 'mano' because it refers to term 'Get-Help -online',
which is not recognized as a cmdlet, function, operable program, or script
 file. Verify the term and try again.
At line:1 char:5
+ mano <<<<  Get-Content
    + CategoryInfo          : ObjectNotFound: (mano:String) [], CommandNo
   tFoundException
    + FullyQualifiedErrorId : AliasNotResolvedException
Run Code Online (Sandbox Code Playgroud)

Gra*_*ray 7

您不能使用这样的参数创建别名.

你可以使用一个功能.就像是...

PS> function mano { Get-Help $args[0] -online }
Run Code Online (Sandbox Code Playgroud)

如果您希望每次启动ps时都可以使用它,那么您可以将它放在您的配置文件中.看$profile.


Eri*_*ris 5

如果你有Powershell v3

$PSDefaultParameterValues = @{
    "Get-Help:Online" = {$True}
}
Run Code Online (Sandbox Code Playgroud)