Remote registry values. Return the string value

248 Views Asked by At

I am trying to return registry values from specific keys. For some reason I can not get the string value of a key. I can get the DWordValue no problem.

Can anyone tell me why the string value won't return?

The code:

function getRegistry(){
    Param (
        [string]$hklm = "2147483650",
        [string]$key = "SOFTWARE\Microsoft\Windows\CurrentVersion\Run",
        [string]$Value2 = "ConnectionCenter"
    )

    $credential = Get-Credential

    $test | ForEach-Object {
        $wmi = Get-WmiObject -List "StdRegProv" -Namespace root\default -ComputerName "compName" -Credential $credential
        #($wmi.GetStringValue($hklm, $key, $value)).sValue

        $wmi.GetStringValue($hklm, $key, $Value2)
    }
}

getRegistry
0

There are 0 best solutions below