Pulling exact Hex string from registry

Welcome Forums General PowerShell Q&A Pulling exact Hex string from registry

This topic contains 3 replies, has 3 voices, and was last updated by

3 years, 5 months ago.

  • Author
  • #29549

    Points: 0
    Rank: Member

    Hello, i have a function that pulls values out of the registry in decimal format, but I'm wanting to pull it so it pulls it exactly as it states it in the registry

    What I mean is say I have a key HKLM:\SOFTWARE\TEST\ key1 with a value ffffffff

    when i run my function it pulls it as a -1 (i'm guess because every thing 7fffffff is a count down back to -1)

    Is there a way to pull the exact hex from the registry? or a method to convert say -1 to it's hex value in the registry?

    function get-registryvalue($regkey, $name)
    (get-itemproperty -path $regkey).$name

    get-registeryvalue hklm:\software\test key1

    >> -1

  • #29552

    Points: 1
    Rank: Member

    PS C:\> '{0:x}' -f -1


    '{0:x}' -f (get-itemproperty -path $regkey).$name

    #PSTip Converting numbers to HEX


  • #29553

    Points: 24
    Team Member
    Rank: Member

    Try to use the format operator -f as shown below:

    '0x{0:x}' -f (get-registeryvalue hklm:\software\test key1)
  • #29556

    Points: 0
    Rank: Member

    Thank you both!

The topic ‘Pulling exact Hex string from registry’ is closed to new replies.

denizli escort samsun escort muğla escort ataşehir escort kuşadası escort