You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

PowerShell创建注册表DWORD后显示异常,如何刷新及是否正常?

注册表操作显示不一致问题及刷新方法

为解决RSAT工具安装时出现的Add-WindowsCapability失败,错误代码0x800f0954问题,执行以下PowerShell命令创建新的DWORD值:

New-ItemProperty -Path HKLM:\Software\Microsoft\Windows\CurrentVersion\Policies\Servicing -Name RepairContentServerSource -Type dword -Value 2

# 命令输出:
RepairContentServerSource : 2
PSPath                    : Microsoft.PowerShell.Core\Registry::HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Policies\Servicing
PSParentPath              : Microsoft.PowerShell.Core\Registry::HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Policies
PSChildName               : Servicing
PSDrive                   : HKLM
PSProvider                : Microsoft.PowerShell.Core\Registry

执行ls HKLM:\Software\Microsoft\Windows\CurrentVersion\Policies\Servicing(ls是Get-ChildItem的别名)命令无任何输出:

ls HKLM:\Software\Microsoft\Windows\CurrentVersion\Policies\Servicing
# 无输出

但执行gp HKLM:\Software\Microsoft\Windows\CurrentVersion\Policies\Servicing(gp是Get-ItemProperty的别名)命令,能看到CountryCode和新建的RepairContentServerSource值:

gp HKLM:\Software\Microsoft\Windows\CurrentVersion\Policies\Servicing

# 命令输出:
CountryCode               : FR
RepairContentServerSource : 2
PSPath                    : Microsoft.PowerShell.Core\Registry::HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Policies\Servicing
PSParentPath              : Microsoft.PowerShell.Core\Registry::HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Policies
PSChildName               : Servicing
PSDrive                   : HKLM
PSProvider                : Microsoft.PowerShell.Core\Registry

另外,执行组合命令(ls HKLM:\Software\Microsoft\Windows\CurrentVersion\Policies | Out-String -Stream | sls RepairContentServerSource).ToString()也能查到该DWORD值:

(ls HKLM:\Software\Microsoft\Windows\CurrentVersion\Policies | Out-String -Stream | sls RepairContentServerSource).ToString()

# 命令输出:
                               RepairContentServerSource : 2

问题

  1. 如何在PowerShell中刷新注册表?
  2. 这种不同命令显示结果不一致的现象是否正常?

内容的提问来源于stack exchange,提问作者SebMa

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.25 16:15:40