Having problems with: alias -?

Topics: Developer Forum, User Forum
Developer
Aug 20, 2010 at 4:04 AM

So I import the HttpRest module ... if I do:

C:\PS> gwpc -?

Get-Help : Cannot find Help for topic "gwpc".
At C:\Users\Joel\Documents\WindowsPowerShell\Modules\PSCX\Modules\GetHelp\Pscx.GetHelp.psm1:481 char:33
+                 $scriptCmd = { & <<<<  $wrappedCmd @PSBoundParameters }
    + CategoryInfo          : ResourceUnavailable: (:) [Get-Help], HelpNotFoundException
    + FullyQualifiedErrorId : HelpNotFound,Microsoft.PowerShell.Commands.GetHelpCommand

Basically I get that with any aliases... but if I type Get-Help gwpc then it works fine. After some debugging, it appears that the parameters you're getting are:

Name = gwpc
Category = Function

But of course, gwpc is an alias, not a Function ... so I added this around line 477:

$outBuffer = $null
if ($PSBoundParameters.TryGetValue('Category', [ref]$outBuffer) -and $outBuffer -notcontains 'Alias')
{
$PSBoundParameters['Category'] += 'Alias' }

And now it works ...

I can't figure out what's going on, but I don't really care -- it works now.

Coordinator
Aug 20, 2010 at 4:23 AM

But does it still work for adv functions & cmdlets?  If so, I'd love to fix this.  Of course, you still have check-in privs so feel free to fix it if you want.  Otherwise, I'll do it - as long as it doesn't break -? help for everything else.  :-)

Developer
Aug 20, 2010 at 4:25 AM

As far as I can tell, it doesn’t break anything, but I’m totally happy to use it for a while to be sure J

From: r_keith_hill [mailto:notifications@codeplex.com]
Sent: Friday, August 20, 2010 12:23 AM
To: jaykul@huddledmasses.org
Subject: Re: Having problems with: alias -? [Pscx:224191]

From: r_keith_hill

But does it still work for adv functions & cmdlets? If so, I'd love to fix this. Of course, you still have check-in privs so feel free to fix it if you want. Otherwise, I'll do it - as long as it doesn't break -? help for everything else. :-)

Read the full discussion online.

To add a post to this discussion, reply to this email (Pscx@discussions.codeplex.com)

To start a new discussion for this project, email Pscx@discussions.codeplex.com

You are receiving this email because you subscribed to this discussion on CodePlex. You can unsubscribe or change your settings on codePlex.com.

Please note: Images and attachments will be removed from emails. Any posts to this discussion will also be available online at codeplex.com

Coordinator
Sep 19, 2010 at 2:59 AM

I'm inclined to go with a fix like this:

   $isAlias = (Microsoft.PowerShell.Core\Get-Command $Name -ErrorAction 'SilentlyContinue').CommandType -eq 'Alias'
    if ($isAlias)
    {
        $PSBoundParameters['Category'] = 'Alias'
    }

What do you think?  So far it seems to work on what I've tested it on.

BTW this seems to be a bug in PowerShell proper.  Try this "man -?" in a PowerShell with no modules/profile loaded.