Powershell 更新失败

2024-02-20

当我跑步时Update-Help它在 Powershell 中失败。我不通过代理。这是直接访问。我还以管理员身份运行 Powershell。我不知道还要检查什么...欢迎任何建议。

这是我的版本。

$PSVersionTable

Name                           Value                                                                                                                                           
----                           -----                                                                                                                                           
PSVersion                      5.1.14393.187                                                                                                                                   
PSEdition                      Desktop                                                                                                                                         
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}                                                                                                                         
BuildVersion                   10.0.14393.187                                                                                                                                  
CLRVersion                     4.0.30319.42000                                                                                                                                 
WSManStackVersion              3.0                                                                                                                                             
PSRemotingProtocolVersion      2.3                                                                                                                                             
SerializationVersion           1.1.0.1   

这是错误:

PS C:\Windows> Update-Help
Update-Help : Failed to update Help for the module(s) : 
'AppBackgroundTask, AppLocker, AppvClient, Appx, AssignedAccess, BitLocker, BitsTransfer, BranchCache, CimCmdlets, ConfigCI, Defender, DirectAccessClientComponents, Dism, 
DnsClient, EventTracingManagement, International, iSCSI, ISE, Kds, Microsoft.PowerShell.Archive, Microsoft.PowerShell.Core, Microsoft.PowerShell.Diagnostics, 
Microsoft.PowerShell.Host, Microsoft.PowerShell.LocalAccounts, Microsoft.PowerShell.Management, Microsoft.PowerShell.ODataUtils, Microsoft.PowerShell.Security, 
Microsoft.PowerShell.Utility, Microsoft.WSMan.Management, MMAgent, MsDtc, MSMQ, NetAdapter, NetConnection, NetEventPacketCapture, NetLbfo, NetNat, NetQos, NetSecurity, 
NetSwitchTeam, NetTCPIP, NetworkConnectivityStatus, NetworkSwitchManager, NetworkTransition, PackageManagement, PcsvDevice, PKI, PnpDevice, PowerShellGet, PrintManagement, 
PSDesiredStateConfiguration, PSReadline, PSScheduledJob, PSWorkflow, PSWorkflowUtility, ScheduledTasks, SmbShare, SmbWitness, StartLayout, Storage, TLS, TroubleshootingPack, 
TrustedPlatformModule, UEV, VpnClient, Wdac, WindowsDeveloperLicense, WindowsErrorReporting, WindowsSearch, WindowsUpdate'
Access is denied. The command could not update Help topics for the Windows PowerShell core modules, or for any modules in the $pshome\Modules directory. To update these Help 
topics, start Windows PowerShell by using the "Run as Administrator" command, and try running Update-Help again.
At line:1 char:1
+ Update-Help
+ ~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (:) [Update-Help], Exception
    + FullyQualifiedErrorId : UpdatableHelpSystemRequiresElevation,Microsoft.PowerShell.Commands.UpdateHelpCommand

Update-Help : Failed to update Help for the module(s) 'Microsoft.PowerShell.Operation.Validation' with UI culture(s) {en-US} : The value of the HelpInfoUri key in the module 
manifest must resolve to a container or root URL on a website where the help files are stored. The HelpInfoUri 'https://www.msn.com/?ocid=NEFLS000' does not resolve to a 
container.
At line:1 char:1
+ Update-Help
+ ~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (:) [Update-Help], Exception
    + FullyQualifiedErrorId : InvalidHelpInfoUri,Microsoft.PowerShell.Commands.UpdateHelpCommand

Update-Help : Failed to update Help for the module(s) 'SecureBoot' with UI culture(s) {en-US} : Unable to retrieve the HelpInfo XML file for UI culture en-US. Make sure the 
HelpInfoUri property in the module manifest is valid or check your network connection and then try the command again.
At line:1 char:1
+ Update-Help
+ ~~~~~~~~~~~
    + CategoryInfo          : ResourceUnavailable: (:) [Update-Help], Exception
    + FullyQualifiedErrorId : UnableToRetrieveHelpInfoXml,Microsoft.PowerShell.Commands.UpdateHelpCommand

I reran Update-Help。我认为它更新了大部分内容。我只收到这些错误。

Update-Help : Failed to update Help for the module(s) 'Microsoft.PowerShell.Operation.Validation' with UI culture(s) {en-US} : The value of the HelpInfoUri 
key in the module manifest must resolve to a container or root URL on a website where the help files are stored. The HelpInfoUri 
'https://www.msn.com/?ocid=NEFLS000' does not resolve to a container.
At line:1 char:1
+ Update-Help
+ ~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (:) [Update-Help], Exception
    + FullyQualifiedErrorId : InvalidHelpInfoUri,Microsoft.PowerShell.Commands.UpdateHelpCommand

Update-Help : Failed to update Help for the module(s) 'AppvClient' with UI culture(s) {en-US} : Help content cannot be found. Make sure the server is 
available and the help content location is properly defined in the HelpInfo XML.
At line:1 char:1
+ Update-Help
+ ~~~~~~~~~~~
    + CategoryInfo          : ResourceUnavailable: (:) [Update-Help], Exception
    + FullyQualifiedErrorId : HelpContentNotFound,Microsoft.PowerShell.Commands.UpdateHelpCommand

Update-Help : Failed to update Help for the module(s) 'SecureBoot' with UI culture(s) {en-US} : Unable to retrieve the HelpInfo XML file for UI culture en-US. 
Make sure the HelpInfoUri property in the module manifest is valid or check your network connection and then try the command again.
At line:1 char:1
+ Update-Help
+ ~~~~~~~~~~~
    + CategoryInfo          : ResourceUnavailable: (:) [Update-Help], Exception
    + FullyQualifiedErrorId : UnableToRetrieveHelpInfoXml,Microsoft.PowerShell.Commands.UpdateHelpCommand

TL;DR 和解决方法

多年后,这仍然是大多数用户的问题。我想我应该在这里给出一个彻底的解释。

两个问题:

  • Update-Help需要 PowerShell 与以管理员身份运行
  • 微软已经破坏了更新链接,这会在每个系统上引发错误。直到今天,您提到的某些模块仍然会抛出错误

您的第一个错误是明显且直接的,此输出直接包含在您的第一个错误输出中:

Access is denied. The command could not update Help topics for the Windows PowerShell core modules, or for any modules in the $pshome\Modules directory. To update these Help 
topics, start Windows PowerShell by using the "Run as Administrator" command, and try running Update-Help again.

To suppress错误,但仍然下载您能够下载的所有内容,您可以运行以下命令(在通过以下方式启动的 PowerShell 控制台中)以管理员身份运行):

Update-Help -Verbose -Force -ErrorAction SilentlyContinue

OR

Update-Help -Verbose -Force -ErrorAction SilentlyContinue -ErrorVariable UpdateErrors

修复 PSReadLine

编辑(2021 年 9 月 1 日): PSReadLine如果这是您要修复的模块之一,则有可用的具体说明:

Rename C:\Program Files\WindowsPowerShell\Modules\PSReadline to C:\Program Files\WindowsPowerShell\Modules\PSReadLine(这是因为它区分大小写,所以我们需要SPReadL一,不是 SPReadline).

不过,可能还需要更多。以下是其中一篇博客文章的完整演练:

  • 关闭所有powershell.exe流程。然后重命名PSReadline模块文件夹名称为PSReadLine.
  • Open an powershell.exe管理员权限的会话。
  • Run Remove-Module PSReadLine删除自动加载的 PSReadLine 模块。
  • Run Import-Module PSReadLine(使用大写的 PSReadLineL).
  • 然后运行Update-Help -Module PSReadLine -Force

引用的博客文章PSReadLine更新修复:

  • https://devblogs.microsoft.com/powershell/updating-help-for-the-psreadline-module/ https://devblogs.microsoft.com/powershell/updating-help-for-the-psreadline-module/
  • https://devblogs.microsoft.com/powershell/updating-help-for-the-psreadline-module-in-windows-powershell-5-1/ https://devblogs.microsoft.com/powershell/updating-help-for-the-psreadline-module-in-windows-powershell-5-1/

解决方法/解决方案的说明

这是一个解释Update-Help -Verbose -Force -ErrorAction SilentlyContinue -ErrorVariable UpdateErrors,它是如何工作的,以及为什么需要这样做,直到微软针对特定模块或针对Update-Help itself.

来自帮助文档Update-Help https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.core/update-help?view=powershell-5.1,这就是需要管理员权限的原因:

更新帮助需要管理权限。

您必须是计算机上管理员组的成员才能更新 PowerShell Core 模块的帮助文件。

要下载或更新 PowerShell 安装目录 ($PSHOME\Modules) 中的模块(包括 PowerShell Core 模块)的帮助文件,请使用“以管理员身份运行”选项启动 PowerShell。例如:启动进程 powershell.exe -Verb RunAs。

您还可以使用 Windows PowerShell 集成脚本环境 (ISE) 中“帮助”菜单中的“更新 Windows PowerShell 帮助”菜单项来更新帮助文件。

更新 Windows PowerShell 帮助项运行不带参数的 Update-Help cmdlet。要更新 $PSHOME 目录中模块的帮助,请使用“以管理员身份运行”选项启动 Windows PowerShell ISE。

至于使用的参数:

  • -Force意味着一些事情,也直接从文档中引用Update-Help https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.core/update-help?view=powershell-5.1:

指示此 cmdlet 不遵循每天一次的限制、跳过版本检查并下载超过 1 GB 限制的文件。

如果没有此参数,Update-Help 仅在每个 24 小时内运行一次。每个模块的下载限制为 1 GB 的未压缩内容,并且仅当帮助文件比计算机上的现有文件新时才会安装帮助文件。

每天一次的限制可以保护托管帮助文件的服务器,并使您可以将 Update-Help 命令添加到 PowerShell 配置文件中,而不会产生重复连接或下载的资源成本。

  • -Verbose只是意味着它将提供一堵黄色文本墙,描述哪些模块正在尝试更新、正在解析的 URI 等。
  • -ErrorVariable UpdateErrors将错误保存到可通过以下方式检索的变量中$UpdateErrors多变的
  • -ErrorAction SilentlyContinue意味着简单地忽略任何错误,并继续进行下一个可以更新的模块

你可能想知道为什么抑制错误被视为修复。这是因为:

  • 如果您有一个运行此命令的脚本,并且您不希望该脚本因这些错误而退出。
  • 它仅抑制无法下载帮助的模块的错误,并且仍然下载所有其他可以下载的模块的帮助。
  • 如果仍然希望调查错误,那么至少可以在$UpdateErrors变量,可以保存到文件或以其他方式处理。
  • 为了真正解决抛出的错误,微软必须采取一些措施来修复他们自己的帮助文档端点。

等等,但为什么这是微软的问题呢?

以下是最新 Windows 10 系统(截至 2019 年第 4 季度/2020 年第 1 季度)的示例:

$PSVersionTable
Name                           Value
----                           -----
PSVersion                      5.1.18362.145
PSEdition                      Desktop
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
BuildVersion                   10.0.18362.145
CLRVersion                     4.0.30319.42000
WSManStackVersion              3.0
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
Get-WmiObject win32_operatingsystem | select Caption, Version
Caption                  Version
-------                  -------
Microsoft Windows 10 Pro 10.0.18363

对于那些在 Windows 上使用 PowerShell 的新手和经验丰富的用户,请参阅这些Update-Help更新帮助文档的第一步中的错误是一个主要的障碍和混乱点。大多数错误并不是用户端的某种错误配置,但不幸的是,它一直是过去几年命令输出的默认和持续期望。

是的,解决方法命令有效。但是,如果人们通过抑制错误输出并继续运行内置命令,这将是一种糟糕的客户体验(如果发生其他错误,这可能不是教导人们的最佳实践?)。抑制错误是人们唯一要做的事情。即使从 2016 年开始,它也是得票最高的答案:

  • PowerShell (5)Update-Help 安装 Windows 10 周年更新后抛出错误 https://social.technet.microsoft.com/Forums/de-DE/fa1da35e-46a8-42de-b5c4-ac423c8d3d39/powershell-5updatehelp-throws-error-after-installing-windows-10-anniversary-update?forum=winserverpowershell

请注意,标记的accepted答案(应该NOT是接受的答案)有关的更新错误HelpInfoUri这里说:

我认为您需要联系微软支持人员来解决这个问题。

问题出在您的机器及其安装上,您需要获得支持来帮助您。我认为我们唯一可以提出的建议就是重新安装Windows。 (!!)

疯狂的事情!如果出现此错误,请勿重新安装!我希望用户没有因为以下原因而重新安装HelpInfoUri错了。

正如所说SamB 在这个 GitHub 问题中,直接专注于尝试解决这个持续存在的问题 https://github.com/MicrosoftDocs/windows-powershell-docs/issues/139#issuecomment-493263344, the HelpInfoURIMicrosoft 在其中设定的值PowerShell 清单文件 https://learn.microsoft.com/en-us/powershell/scripting/developer/module/how-to-write-a-powershell-module-manifest?view=powershell-7有过错:

Well, WindowsUpdateProvider 的模块清单 https://gist.github.com/SamB/da46329bf616f47faf5ce0224f166e46在这台机器上没有给出任何超出“Microsoft Corporation”的归属,但它确实指定了一个HelpInfoUri of https://go.microsoft.com/fwlink/?linkid=390794 https://go.microsoft.com/fwlink/?linkid=390794,所以实际上没有必要费力地弄清楚模块来自哪里,并以某种方式证明这需要向 WindowsUpdateProvider 发布补丁——只需将重定向指向适当的地方即可。

如果您在系统上运行以下命令Update-Help出现错误,您应该看到输出:

Import-Module WindowsUpdateProvider
Get-Module WindowsUpdateProvider | select HelpInfoURI,Version                                                                                                                                                                                      
HelpInfoUri                                    Version
-----------                                    -------
https://go.microsoft.com/fwlink/?linkid=390794 1.0.0.2

使用源模块清单Windows更新提供程序,例如,位于此处:

C:\WINDOWS\system32\WindowsPowerShell\v1.0\Modules\WindowsUpdateProvider\WindowsUpdateProvider.psd1

微软绝对可以将链接重定向到一个有效的HelpInfoUri,这意味着客户端的零变化。

顺便说一句,人们使用-ErrorAction SilentlyContinue通常情况下,其他几个模块的帮助已被破坏。截至今天,这些在标准 Windows 10 桌面上已被破坏:

$TestModules = @("Microsoft.PowerShell.ODataUtils", "Microsoft.PowerShell.Operation.Validation", "UEV", "Whea", "WindowsDeveloperLicense", "defender", "configdefender",  "appvclient")
Import-Module $TestModules
$BorkedHelp = Get-Module $TestModules | select Name, Version, HelpInfoUri
$BorkedHelp
Name                                      Version   HelpInfoUri
----                                      -------   -----------
appvclient                                1.0.0.0   https://go.microsoft.com/fwlink/?LinkId=403112
configdefender                            1.0       https://go.microsoft.com/fwlink/?linkid=390762
defender                                  1.0       https://go.microsoft.com/fwlink/?linkid=390762
Microsoft.PowerShell.ODataUtils           1.0       https://go.microsoft.com/fwlink/?LinkId=509916
Microsoft.PowerShell.Operation.Validation 1.0.1     https://go.microsoft.com/fwlink/?LinkId=808399
UEV                                       2.1.639.0 https://go.microsoft.com/fwlink/?LinkId=826061
Whea                                      2.0.0.0   https://go.microsoft.com/fwlink/?linkid=390848
WindowsDeveloperLicense                   1.0.0.0   https://go.microsoft.com/fwlink/?linkid=285578
foreach ($uri in $BorkedHelp.helpinfouri) {Invoke-WebRequest $uri}

欢迎来到红色的海洋404 - File or directory not found.错误,所有端点都需要重定向。目前,一些端点已经被打破多年,而另一些端点的打破时间可能更少。

这些应该可以由微软修复,无论他们有什么关于链接转发的工具,除非他们更新模块清单本身以指向新工作HelpInfoURI端点,这对所有用户来说都是不太友好的选择。

如果微软的问题是默认情况下没有可下载的文档,并且链接可能是自动生成的保留,供以后有文档下载时使用,那么它们至少应该有一个最低限度的链接HelpInfoURI端点而不是损坏的端点。

帮助让 Microsoft 意识到

Users who run into this problem, and found this explanation helpful, should visit this issue on GitHub: MicrosoftDocs/windows-powershell-docs: Update-Help fails for WindowsUpdateProvider https://github.com/MicrosoftDocs/windows-powershell-docs/issues/139

编辑(2021 年 9 月 1 日):上述问题已被关闭,并且 Microsoft 不再使用 UserVoice 进行反馈(在问题关闭时被提及为适当的位置)。看起来最好的选择是去Microsoft 技术社区:PowerShell https://techcommunity.microsoft.com/t5/powershell/ct-p/WindowsPowerShell,由于 Microsoft 支持文档中有关 UserVoice 的通知:

注意:我们将在 2021 日历年中逐个产品地放弃 UserVoice 反馈网站。我们将利用第一方解决方案来获取客户反馈。参考 https://support.microsoft.com/en-us/office/uservoice-pages-430e1a78-e016-472a-a10f-dc2a3df3450a

如果任何有问题的 PowerShell 模块都有公共存储库,那么这些模块将是适当的位置,否则会引发有关损坏的问题Update-Help功能。如果它是 Microsoft 产品附带的 PowerShell 模块,则需要通过某种向产品本身报告的方式提出问题。

另一种修复方法

对于任何已知的帮助文档端点已损坏的 PowerShell 模块,您还可以注释掉HelpInfoURIPowerShell 清单中的值。Update-Help仅尝试下载模块的更新HelpInfoURI有一个价值。这可能有助于了解是否由于端点问题(例如HelpInfoURI托管您自己的模块文档)。

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

Powershell 更新失败 的相关文章

随机推荐

  • PostgresQL SQL:将结果转换为数组

    查询如下 SELECT i adgroup id i category id FROM adgroupcategories br WHERE i adgroup id IN SELECT i adgroup id FROM adgroupu
  • 将数据帧写入 postgres 数据库

    我想将 pandas 数据帧写入 postgres 表 我按如下方式连接到数据库 import psycopg2 import pandas as pd import sqlalchemy def connect user password
  • React 模块解析失败:意外的标记 (1:48)

    有人能帮我吗 我只是创建反应应用程序 然后立即启动它 然后我收到了类似这样的错误 我对 webpack 不太了解 CMD src index js 1 48 Module parse failed Unexpected token 1 48
  • 重置 Keras 层中的权重

    我想重置 随机化 Keras 深度学习 模型中所有层的权重 原因是我希望能够使用不同的数据分割多次训练模型 而不必每次都进行 缓慢的 模型重新编译 灵感来自这次讨论 https github com fchollet keras pull
  • UNIX 中“./”和“sh”的区别

    有时我发现很少有脚本是通过 sh 命令执行的 有时是通过 命令执行的 我无法理解它们之间的确切区别 请帮助我 sh file在新的 shell 进程中执行 shell 脚本文件 file在当前 shell 进程中执行 shell 脚本文件
  • 命令行终端上的乘法

    我正在使用串行终端为我们的实验室实验提供输入 我发现使用 echo 5X5 只返回一个字符串 5X5 有没有执行乘法运算的命令 是的 您可以使用bash 的内置算术扩展 https www gnu org software bash man
  • 如何解决“不支持关键字:‘元数据’”?

    我无法连接到 SQL Server 我的项目的连接字符串是
  • 使用图权重提升深度优先访问者最小生成树

    我想从具有边权重的顶点创建最小生成树 并以深度优先顺序遍历图 我可以构建图表和最小生成树 但我无法编写自定义访问者 include
  • WinHttpSendRequest 失败并显示 ERROR_WINHTTP_SECURE_FAILURE

    以编程方式与网络进行通信不是我的专业领域 但我设法通过从网上找到的示例中剪切和粘贴代码来创建 read web page 函数 并且该代码已经连续好几个月每天正常运行 碰巧的是 我工作时的主 Windows 10 电脑坏了 在等待维修时 我
  • PHP - 读取和修复大型无效 XML 文件

    我必须读取一些相当重的 XML 文件 200 MB 到 1 GB 之间 其中一些文件是无效的 让我举一个小例子
  • 为什么最终没有被调用?

    我有几个关于java中的垃圾收集器的问题 Q1 据我了解 当对象超出范围并且 JVM 即将收集垃圾时 finalize 就会被调用 我认为 Finalize 方法是由垃圾收集器自动调用的 但在这种情况下它似乎不起作用 解释是什么 为什么需要
  • ObjC Plist 文件读取比 JSON 快?

    我做过这个测试项目https github com danielpetroianu FileDeserializeBenchmarking https github com danielpetroianu FileDeserializeBe
  • jQuery 错误? .appendTo() 在 IE7 中不起作用

    我正在尝试为 jQuery 创建一个选项传输插件 我可以在 Opera Firefox Chrome 和 Safari 中使用基本功能 但 IE7 无法配合 IE7 中的传递函数的运行似乎非常零散且难以理解 我创造了一个示例页面来说明我的问
  • Three.JS - 粒子沿随机方向绕点运行形成球体

    我有一个粒子系统 其中所有粒子都位于相同的坐标处 并且在随机方向上一个接一个地 它们 应该 开始绕场景中心运行 形成一个球体 到目前为止 我成功实现的是一组 Vector3 对象 粒子 它们一个接一个地开始沿着 Z 轴绕中心运行 只需根据当
  • 将 bigint 转换为日期时间

    我想将一个值从 bigint 转换为 datetime 例如 我正在阅读HISTORY表的团队城市服务器 在场上构建启动时间服务器 我在一条记录 1283174502729 上有这个值 如何将其转换为日期时间值 这对你有用吗 它在 SQL
  • xsl string-join() 多个变量 - 仅使用非空

    我想创建几个 xsl variable 它们可能为空 也可能不为空 然后加入它们
  • BigQuery 中有自动增量吗?

    BigQuery 中是否有 AUTO INCRMENT SERIAL IDENTITY 或序列之类的内容 我知道 ROW NUMBERhttps cloud google com bigquery query reference row n
  • 如何快速检查是否使用 Perl 安装了 Linux `unzip`?

    如何快速检查是否是Linuxunzip是使用 Perl 安装的吗 which unzip 如果有输出 则它指向解压缩的位置 如果没有输出 则不会显示任何内容 这依赖于解压缩在您的路径上
  • UISegmentedControl setSelectedSegmentIndex:没有 valueChanged 操作

    我正在通过代码设置 UISegmentedControl 的 selectedSegmentIndex 每当我这样做时 就会调用 valueChanged 操作 这对我来说听起来很合乎逻辑 但是有没有办法在不调用操作的情况下设置选定的段 它
  • Powershell 更新失败

    当我跑步时Update Help它在 Powershell 中失败 我不通过代理 这是直接访问 我还以管理员身份运行 Powershell 我不知道还要检查什么 欢迎任何建议 这是我的版本 PSVersionTable Name Value