I am frequently making calls such as:

get-help <some-command>

in Powershell 2. For many, but not all, of these commands, I am not shown the contents of the help entry. Instead, I get duplicates, and only the help object itself is displayed:

[PS2]> get-help remove-distributiongroup | more

Name                              Category  Synopsis
----                              --------  --------
Remove-DistributionGroup          Cmdlet    Use the Remove-DistributionGroup...
Remove-DistributionGroup          Cmdlet    Use the Remove-DistributionGroup...

Being a complete PS novice, I hack around this by doing something similar to the following:

[PS2]> $var = get-help remove-distributiongroup
[PS2]> $var[0] | get-member
... Output ...
[PS2]> $var[0].Parameters |more
... Part of the documentation ...
[PS2]> $var[0].Synopsis |more
... Another part of the documentation ...

Couple of questions.

  • Will my Windows admin co-workers know how to remove the duplicate entries? I'm just a Unix guy.
  • If not, is there an easier method to get what I need instead of the convoluted hack I came up with above?

Thanks!

[UPDATE[:

Tried pk's suggestion, but sadly that didn't work. Here's the output when piped through select -unique:

Name                              Category  Synopsis
----                              --------  --------
Get-DistributionGroup             Cmdlet    Use the Get-DistributionGroup cm...
link|improve this question

40% accept rate
dont pipe to more thats automatic for one, other then that this is nuts can't repo. – tony roth Sep 20 '11 at 22:12
you don't have cygwin loaded by chance? – tony roth Sep 20 '11 at 22:13
@tony - nope, no cygwin loaded. – Larold Sep 20 '11 at 23:56
feedback

2 Answers

This is probably caused by duplicate PS Snapins loaded. If you are in the Exchange Management Shell and then load the Exchange 2010 management snapin (maybe in a script?), you will see these duplicate get-help responses. While running the EMS run get-pssnapin and check for the E2010 snapin. If it's there, use remove-pssnapin to unload it.

See "Get-Help Produces Duplicate Topics" for more info.

link|improve this answer
feedback

I'm not sure why you're getting duplicates. I can't recreate the issue, but I do have on idea as to how to workaround it in a slightly more elegant fashion.

get-help remove-distributiongroup | select -unique

Does that work?

What does this return?

Test-Path -path "$pshome\Help.format.ps1xml"

This file contains the formatted views for MamlCommandHelpInfo objects that are returned by Get-Help.

link|improve this answer
Unfortunately, nope. Instead of seeing two entries, I get one. See answer above as comments don't allow for indented code that I know of. – Larold Sep 20 '11 at 19:45
I'll let you know what I get tomorrow - got sidetracked by another project. Thanks for the suggestion - will try. – Larold Sep 20 '11 at 23:56
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.