Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Creating Alias to `man` with arguments -online?

Tags:

powershell

I want to create an alias for Get-Help [foo] -online. But I can't get arguments to work.

I tried a few things including 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
like image 521
ninMonkey Avatar asked Dec 15 '22 08:12

ninMonkey


2 Answers

You can't create an alias with arguments like that.

You can use a function though. Something like...

PS> function mano { Get-Help $args[0] -online }

If you want this to be available every time you start ps, then you can put it in your profile. see $profile.

like image 199
Gray Avatar answered Jan 04 '23 02:01

Gray


If you have Powershell v3

$PSDefaultParameterValues = @{
    "Get-Help:Online" = {$True}
}
like image 35
Eris Avatar answered Jan 04 '23 02:01

Eris