Home > Blockchain >  How do I change a REG_DWORD value's base from Hexadecimal to Decimal via PowerShell cmdlets?
How do I change a REG_DWORD value's base from Hexadecimal to Decimal via PowerShell cmdlets?

Time:07-06

For a private preview tool provided by Microsoft, a registry value needs to be set to Type REG_DWORD value 46, then change the Base from hexadecimal to decimal. Here is a portion of the documentation I am referring to:

  1. Use the Edit menu or right-click to create a new DWORD (32-bit) Value and name it WUfBDF (note the only lowercase letter in this name is the 3rd ‘f’ and all the rest are uppercase).
  2. Next, right-click on the new value and select the Modify… option.
    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

I read the Set-ItemProperty documentation enter image description here

enter image description here

And it shows both values in the main details pane:

enter image description here

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.

  • Related