I'm attempting to use WMI to access a registry remotely via powershell. I'm using the following code to do this:
$regUserPass = ConvertTo-SecureString -string "secret" -AsPlainText -Force
$credentials = new-object System.Management.Automation.PSCredential("username", $regUserPass)
$wmiReg = Get-WmiObject -list -namespace root\default -computerName $serverName -credential $credentials | where-object { $_.name -eq "StdRegProv" }
$wmiReg.GetStringValue($REG_LOCAL_MACHINE_CODE, $REG_SERVER_KEY, "strClientConfig").sValue
When I execute it, I get the following error:
Exception retrieving member "GetStringValue": "Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED))"
I'm fairly sure that the user account I'm using has the appropriate rights to access the registry remotely. I granted the user all rights via wmimgmt.msc to the ROOT namespace and all sub-namespaces, so I have no idea why I'm getting an access denied error. Is there something that I'm missing?