如何通过powershell cmdlet将reg_dword值从十六进制更改为十进制?
对于由Microsoft提供的私人预览工具,需要将注册表值设置为键入reg_dword值46,然后将基数从十六进制更改为十进制。 Here is a portion of the documentation I am referring to:
- Use the Edit menu or right-click to create a new DWORD (32-bit) 值和命名wufbdf(请注意此处唯一的小写字母 名称是第三'f',其余的都是大写)。
- 接下来,右键单击新值,然后选择“修改…”选项。
Make sure to choose the Decimal base and set the value to 46.
I am creating a Proactive remediation script to push out to a group of machines that need this Reg key/item for the preview tool to work.
$regkeyPath = "HKLM:\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate"
$regEntry = "WUfBDF"
$desiredValue = 46
function createRegEntry($path, $entry, $value){
write-output "Remediating registry entry."
if(test-path -Path $path){
write-output "$path exists. Setting $entry"
Set-ItemProperty -Path $path -Name $entry -Value $value -Type DWord -force | out-null
}else{
New-Item -Path $Path -Force
New-ItemProperty -Path $path -Name $entry -Value $value -PropertyType DWord -force | out-null
}
}
createRegEntry $regkeyPath $regEntry $desiredValue
我读了set-itemproperty文档此处来自Microsoft文档,似乎在创建时似乎reg-dword值的基本默认值是十六进制,必须手动更改。将其更改为reg_dword的任何方法都以十进制为基础
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
Regedit UI中的“基础”选项对于用户来说是一个方便。这些说明可以很容易地说“将基础设置为十六进制并输入2E” - 它们都是相同的数字。有时,使用十六进制号码 - 例如
0xf000
(HEX)而不是61440
(十进制),反之亦然。In fact, if you set the dialog to Decimal, enter 46 and then change to Hexadecimal you'll see the "Value data" change to 2e automatically...
And it shows both values in the main details pane:
Similarly, when writing your PowerShell code you could write
$desiredValue = 46
或$ desiredValue = 0x2e
并获得相同的结果。它们都是相同数字的表示形式 - 一个小数点和一个十六进制 - 仅取决于您使用哪种格式。The "base" option in the regedit UI is a convenience for the user. The instructions could just as easily have said "set base to Hexadecimal and enter 2e" - they're both the same number. Sometimes it's just easier to work with a hex number - e.g.
0xF000
(hex) instead of61440
(decimal) or vice versa.In fact, if you set the dialog to Decimal, enter 46 and then change to Hexadecimal you'll see the "Value data" change to 2e automatically...
And it shows both values in the main details pane:
Similarly, when writing your PowerShell code you could write
$desiredValue = 46
or$desiredValue = 0x2E
and get the same result. They're both representations of the same number - one decimal and one hexadecimal - it just depends on your preference which format you use.