5

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...
3
  • dont pipe to more thats automatic for one, other then that this is nuts can't repo.
    – tony roth
    Commented Sep 20, 2011 at 22:12
  • you don't have cygwin loaded by chance?
    – tony roth
    Commented Sep 20, 2011 at 22:13
  • @tony - nope, no cygwin loaded.
    – Larold
    Commented Sep 20, 2011 at 23:56

5 Answers 5

3

Below script is working for me, to remove duplicate entries in Get-Help:

$sys32Help = Get-ChildItem -Path "C:\Windows\System32\WindowsPowerShell\v1.0\en-US\" -Filter {*help*}
$sys32ModHelp = Get-ChildItem -Path "C:\Windows\System32\WindowsPowerShell\v1.0\Modules" -Filter {*help*} -Recurse -File
$compare = Compare-Object -ReferenceObject $sys32Help -DifferenceObject $sys32ModHelp -Property name -IncludeEqual
$compEQ = $compare | where sideIndicator -eq == | Select name | %{ $_.Name }
$sys32ModHelp | ?{ $_.Name -in $compEQ } | %{ Remove-Item -Path $_.FullName -Force -ErrorAction SilentlyContinue}
1
  • 1
    Thanks! This one worked for me as well with duplicate help files in the Modules folder, Windows 7, Powershell 5. Note: Run as administrator needed.
    – Eelco L.
    Commented May 3, 2018 at 8:00
2

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.

2
  1. never use "more" in powershell. more uses the default formatter (which format-table also uses.)
  2. if you had used the Format-list commandlet, you would have found that get-help returns an object with a 'pssnapin' property or a 'modulename' property.

The default formatter can mislead, but format-list or using get-member commandlet will list all the properties. I'll bet if you re-ran your command with a user format you would get: [PS2]> get-help remove-distributiongroup | select name,synopsis,modulename,pssnapin

Name                      Category  Synopsis                            PsSnapin
----                      --------  --------                            --------
Remove-DistributionGroup  Cmdlet    Use the Remove-DistributionGroup... ASnapin
Remove-DistributionGroup  Cmdlet    Use the Remove-DistributionGroup... AnotherSnapin

(above output is not real) But the nub of it is you would be able to see which module has the duplicate command.

It's not a duplicate really, because you can call each command like so Asnapin\Remove-DistributionGroup or AnotherSnapin\Remove-DistributionGroup to use the other version :)

0

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.

2
  • 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
    Commented Sep 20, 2011 at 19:45
  • I'll let you know what I get tomorrow - got sidetracked by another project. Thanks for the suggestion - will try.
    – Larold
    Commented Sep 20, 2011 at 23:56
0

I have run into some instances where people trying to run the Get-Help command with Exchange 2010, 2013 get duplicate cmdlet listings instead of the actual help content. This was most likely from running a script that loaded the PSSnapin for Microsoft.Exchange.Management.PowerShell.E2010. Here is what you can do to remove this specific and maybe other duplicate entries:

To bypass the issue quickly:

Just run: Get-Help <cmdlet name> -Category 'Function' -full

Example:

Get-Help Get-MailboxFolderPermission -Category 'Function' -full

Otherwise to get more info and resolve the issue:

This command shows the help entry related data for the command and will also return the snapin name which we will need later:

Get-Help Get-Mailbox | Select Name,PSSnapIn

This command shows the full command related data for the command:

Get-Command Get-Mailbox | Select Name,CommandType

Check the CommandType in this output. You will probably see the command type for one is listed as a Cmdlet and the other is listed as a Function. This most likely occurred because at some point the Exchange Management Snapin was added manually or via a script that was run. Since the Exchange management shell sets up the shell as needed, the snapin should not have been loaded so it should be removed.

Use this command to remove the snapin:

Remove-PSSnapin -Name <name of snapin from 1st command above>

Example:

Remove-PSSnapin -Name Microsoft.Exchange.Management.PowerShell.E2010

This will remove the snapin and leave the individual functions which get loaded when you launch the Exchange Management Shell.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .