{"id":18928,"date":"2021-03-11T07:29:00","date_gmt":"2021-03-11T15:29:00","guid":{"rendered":"https:\/\/devblogs.microsoft.com\/powershell\/?p=18928"},"modified":"2022-07-21T14:54:28","modified_gmt":"2022-07-21T22:54:28","slug":"updating-help-for-the-psreadline-module-in-windows-powershell-5-1","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/powershell\/updating-help-for-the-psreadline-module-in-windows-powershell-5-1\/","title":{"rendered":"Updating help for the PSReadLine module in Windows PowerShell 5.1"},"content":{"rendered":"<p>The version of the <strong>PSReadline<\/strong> module that shipped in Windows PowerShell 5.1 used a lowercase letter in the name. The name of the module was changed for the release of PowerShell 6. It now uses a capital <code>L<\/code> in the name.<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/powershell\/wp-content\/uploads\/sites\/30\/2020\/11\/update-help-error.png\" alt=\"Error updating PSReadLine help\" \/><\/p>\n<p>In the example above, I am trying to update help for the <strong>PSReadLine<\/strong> module on my Windows computer. Take a close look at the error message. Notice the spelling of the module name in the message:<\/p>\n<blockquote><p>Failed to update Help for the module(s) &#8216;<strong>PSReadline<\/strong>&#8216;<\/p><\/blockquote>\n<p>In PowerShell 6 and higher, the <strong>PSReadLine<\/strong> module is spelled with a capital <strong><code>L<\/code><\/strong> character. But the error message is using a lowercase letter.<\/p>\n<h2>The root cause of the error<\/h2>\n<p>The problem comes from Windows PowerShell 5.1. The version of the <strong>PSReadline<\/strong> module that shipped in Windows PowerShell 5.1 used a lowercase letter in the name. The name of the module was changed for the release of PowerShell 6. It now uses a capital <code>L<\/code> in the name.<\/p>\n<p>The <code>Update-Help<\/code> cmdlet constructs the URL of the CAB file containing the updated help. The URL path is case-sensitive. The updated help files use the new name with the capital <code>L<\/code>. PowerShell 6 and higher is installed side-by-side with Windows PowerShell. When you run <code>Update-Help<\/code>, the cmdlet attempts to update the help for both versions of PowerShell. The name of the module that<code> Update-Help<\/code> uses is based on the name of the folder where the help is stored. For Windows PowerShell this is <code>C:\\Program Files\\WindowsPowerShell\\Modules\\PSReadline<\/code>.<\/p>\n<p>Note that only the update of help for the Windows PowerShell location is failing.<\/p>\n<h2>How to fix this problem<\/h2>\n<p>Fortunately the fix is simple. Just rename the folder to<code> C:\\Program Files\\WindowsPowerShell\\Modules\\PSReadLine<\/code>. To rename this folder, you must be sure to close all Windows PowerShell sessions to release any open file handles on the directory. If you try to rename the folder from the PowerShell command line, you receive the following error message.<\/p>\n<blockquote><p><code>Rename-Item: Source and destination path must be different.<\/code><\/p><\/blockquote>\n<p>There are two simple ways to rename the folder.<\/p>\n<ul>\n<li>From an elevated PowerShell session, run the following command:<\/li>\n<\/ul>\n<p style=\"padding-left: 40px;\"><code>cmd \/c ren \"C:\\Program Files\\WindowsPowerShell\\Modules\\PSReadline\" PSReadLine<\/code><\/p>\n<ul>\n<li>Use the Windows File Explorer to rename the file.<\/li>\n<\/ul>\n<h2>Update-Help still fails in Windows PowerShell 5.1<\/h2>\n<p>Even after renaming the folder, you still get the same error when you try to update help for Windows PowerShell 5.1.<\/p>\n<blockquote><p><span style=\"font-size: 1rem;\">The root problem in Windows PowerShell 5.1 is that the module is automatically loaded at startup <\/span><span style=\"font-size: 1rem;\">using the <\/span><strong style=\"font-size: 1rem;\">PSReadline<\/strong><span style=\"font-size: 1rem;\"> name (with the lowercase <\/span><strong><code>l<\/code><\/strong><span style=\"font-size: 1rem;\">). Use the following steps workaround this <\/span><span style=\"font-size: 1rem;\">problem and update the help.<\/span><\/p><\/blockquote>\n<ol>\n<li>Open an elevated <code>powershell.exe<\/code> session (Run as\u00a0 Administrator).<\/li>\n<li>Run <code>Remove-Module PSReadLine<\/code> to remove the auto-loaded <strong>PSReadLine<\/strong> module.<\/li>\n<li>Run <code>Import-Module PSReadLine<\/code> (use <strong>PSReadLine<\/strong> with capital <code>L<\/code>).<\/li>\n<li>Then run <code>Update-Help -Module PSReadLine -Force<\/code><\/li>\n<\/ol>\n<p>These steps load the module in your session using the proper name, which allows <code>Update-Help<\/code> to use the correct name to find the help content. You may consider adding the <code>Remove-Module<\/code> and <code>Import-Module<\/code> commands to your profile script for Windows PowerShell 5.1.<\/p>\n<p>In the following screen shot you can see that PSReadLine is loaded in the session using the lowercase <code><strong>L<\/strong><\/code>. After removing the module and reimporting it, the correct name is loaded in the session.<\/p>\n<p style=\"padding-left: 40px;\"><a href=\"https:\/\/devblogs.microsoft.com\/powershell\/wp-content\/uploads\/sites\/30\/2021\/03\/psr-reload.png\"><img decoding=\"async\" class=\"alignnone wp-image-19612\" src=\"https:\/\/devblogs.microsoft.com\/powershell\/wp-content\/uploads\/sites\/30\/2021\/03\/psr-reload-300x187.png\" alt=\"Image psr reload\" width=\"888\" height=\"554\" srcset=\"https:\/\/devblogs.microsoft.com\/powershell\/wp-content\/uploads\/sites\/30\/2021\/03\/psr-reload-300x187.png 300w, https:\/\/devblogs.microsoft.com\/powershell\/wp-content\/uploads\/sites\/30\/2021\/03\/psr-reload-1024x639.png 1024w, https:\/\/devblogs.microsoft.com\/powershell\/wp-content\/uploads\/sites\/30\/2021\/03\/psr-reload-768x479.png 768w, https:\/\/devblogs.microsoft.com\/powershell\/wp-content\/uploads\/sites\/30\/2021\/03\/psr-reload.png 1059w\" sizes=\"(max-width: 888px) 100vw, 888px\" \/><\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Describes how to workaround the error when you try to update help for PSReadline in Windows PowerShell 5.1.<\/p>\n","protected":false},"author":7674,"featured_media":13641,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1],"tags":[248,3168,3167],"class_list":["post-18928","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-powershell","tag-powershell","tag-psreadline","tag-update-help"],"acf":[],"blog_post_summary":"<p>Describes how to workaround the error when you try to update help for PSReadline in Windows PowerShell 5.1.<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/posts\/18928","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/users\/7674"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/comments?post=18928"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/posts\/18928\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/media\/13641"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/media?parent=18928"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/categories?post=18928"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/tags?post=18928"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}