Pulling exact Hex string from registry

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

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

therefore

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

http://ss64.com/ps/syntax-f-operator.html

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

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

Thank you both!