gpt4 book ai didi

PowerShell 如何抑制错误消息

转载 作者:行者123 更新时间:2023-12-03 00:06:44 26 4
gpt4 key购买 nike

每当我运行 Update-Help 时,都会遇到大量错误。我已经放弃尝试解决这些问题,这就是 PowerShell 的工作方式,一些帮助文件定义总是无法更新(但如果有人知道如何解决这些问题,我将有兴趣尝试)。

所以,我想抑制每月更新这些东西的脚本中的错误。

我试过 Update-Help -EA silentUpdate-Help -EA silent | Out-Null 但在这两种情况下,错误消息仍以红色喷洒在屏幕上。

有谁知道热压制这些吗?

Update-Help : Failed to update Help for the module(s) 'AppvClient, ConfigDefender, Defender, HgsClient, HgsDiagnostics,
HostNetworkingService, Microsoft.PowerShell.ODataUtils, Microsoft.PowerShell.Operation.Validation, Sudo, UEV, Whea,
WindowsDeveloperLicense' with UI culture(s) {en-GB} : Unable to connect to Help content. The server on which Help content is stored
might not be available. Verify that the server is available, or wait until the server is back online, and then try the command again.
At C:\Users\Boss\AppData\Local\Temp\BeginSystemConfig.ps1:571 char:9
+ Update-Help
+ ~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [Update-Help], Exception
+ FullyQualifiedErrorId : UnableToConnect,Microsoft.PowerShell.Commands.UpdateHelpCommand

Update-Help : Failed to update Help for the module(s) 'WindowsUpdateProvider' with UI culture(s) {en-GB} : Unable to retrieve the
HelpInfo XML file for UI culture en-GB. Make sure the HelpInfoUri property in the module manifest is valid or check your network
connection and then try the command again.
At C:\Users\Boss\AppData\Local\Temp\BeginSystemConfig.ps1:571 char:9
+ Update-Help
+ ~~~~~~~~~~~
+ CategoryInfo : ResourceUnavailable: (:) [Update-Help], Exception
+ FullyQualifiedErrorId : UnableToRetrieveHelpInfoXml,Microsoft.PowerShell.Commands.UpdateHelpCommand

最佳答案

这将帮助您:

Update-Help -ErrorAction SilentlyContinue

或者

Try {
Update-Help -ErrorAction Stop
# Use this method only if you want to halt script on errors
}
Catch {
# Place action on error here
}

关于PowerShell 如何抑制错误消息,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59694632/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com