Fixing PowerShell 5 Help Bug

by Nov 24, 2016

When you download PowerShell help via Update-Help, there was a bug in PowerShell 5 that might be fixed by now: text-based help files had the extension “.txt” rather than “.help.txt”, so PowerShell help would ignore them. Check for yourself – the command below should return tons of about topics:

 
PS C:\> Get-Help about*

Name                              Category  Module                    Synopsis                                              
----                              --------  ------                    --------                                              
about_Aliases                     HelpFile                            SHORT DESCRIPTION                                     
about_Arithmetic_Operators        HelpFile                            SHORT DESCRIPTION                                     
about_Arrays                      HelpFile                            SHORT DESCRIPTION                                     
about_Assignment_Operators        HelpFile                            SHORT DESCRIPTION                                     
about_Automatic_Variables         HelpFile                            SHORT DESCRIPTION                                     
about_Break                       HelpFile                            SHORT DESCRIPTION                                     
about_Classes                     HelpFile                            SHORT DESCRIPTION                                     
about_Command_Precedence          HelpFile                            SHORT DESCRIPTION                                     
about_Command_Syntax              HelpFile                            SHORT DESCRIPTION                                     
about_Comment_Based_Help          HelpFile                            SHORT DESCRIPTION                                     
about_CommonParameters            HelpFile                            SHORT DESCRIPTION                                     
about_Comparison_Operators        HelpFile                            SHORT DESCRIPTION                                     
about_Continue                    HelpFile                            SHORT DESCRIPTION                                     
about_Core_Commands               HelpFile                            SHORT DESCRIPTION                                     
about_Data_Sections               HelpFile                            SHORT DESCRIPTION                                     
about_Debuggers                   HelpFile                            SHORT DESCRIPTION                                     
about_DesiredStateConfiguration   HelpFile                            SHORT DESCRIPTION 
 

If it does not, you either never ran Update-Help to download the help files in the first place, or you are bitten by the bug.

Whether or not this bug is fixed meanwhile, with PowerShell you can correct these things easily. Here is a script that would fix the file extension for all affected help files.

This script does require Administrator privileges because help files reside inside the protected Windows folder:

# find all text files inside the PowerShell folder that start
# with "about"
Get-ChildItem -Path $pshome -Filter about*.txt -Recurse |
  # identify those that do not end with ".help.txt"
  Where-Object { $_.Name -notlike '*.help.txt' } |
  # rename the extension using a regex:
  Rename-Item -NewName { $_.Name -replace '\.txt$', '.help.txt'}

Twitter This Tip! ReTweet this Tip!