Powershell Microsoft.win32.registrykey Openremotebasekey Credentials

Posted : admin On 13.01.2020

  1. Powershell Microsoft.win32.registrykey Openremotebasekey Credentials Manager

I've been using the very helpful PSRemoteRegistry module to gather information from multiple servers on my network. However, I've found that it throws an error when requesting Registry information if the server name includes a hyphen.This code:$Date = Get-RegValue -ComputerName $Computer.Name -Key 'SOFTWAREMicrosoftWindowsCurrentVersionWindowsUpdateAuto UpdateResultsInstall' -Value LastSuccessTimeworks just fine if $Computer.Name contains something like 'Server1' but it fails when it contains something like 'SQL-Server'. It appears that it is breaking the name into two parts.The failing code in the function in Get-RegValue is:$reg = Microsoft.Win32.RegistryKey::OpenRemoteBaseKey(Microsoft.Win32.RegistryHive$Hive,$c)The error is:Exception calling 'OpenRemoteBaseKey' with '2' argument(s): 'The network path was not found.' At C:Windowssystem32WindowsPowerShellv1.0ModulesPSRemoteRegistryGet-RegValue.ps1:261 char:5+. $reg = Microsoft.Win32.RegistryKey::OpenRemoteBaseKey(.+ + CategoryInfo: NotSpecified: (:) , MethodInvocationException+ FullyQualifiedErrorId: IOExceptionAny help with a way around this problem would be really appreciated.

Powershell Microsoft.win32.registrykey Openremotebasekey Credentials Manager

DETall,Thank you for the information on dashing or hyphenating names in PowerShell;I've tried submitting the variable surrounded by quotes (both in my script and in the script called by Get-RegValue) with exactly the same result. I'm supplying a variable name that does not include a dash or hyphen - it is the information contained inside the variable that is dashed.or hyphenated. That information is passed to a.Net framework method (RegistryKey.OpenRemoteBaseKey) in this library:mscorlib. That method seems to be unable to handled dashed or hyphenated information.

Chamele0n,Thank you for the suggestion. I checked with the get-service as you suggested. It found no service. So, I went to the server to check and found that the Remote Registry service was not running. I started it. I also checked for any dependencies and started RPC as well.

I then returned to my code and again tried the get-service call. It still was unable to find any service by that name. I tried it on the local computer, worked fine. I tried it on a different remote computer without a hyphen in the name, worked fine. Also, with the Remote Registry on my code still is unable to get to the registry on the machine with a hyphenated name.So, I'm am back to the conclusion that hyphenated names for servers do not work through PowerShell.Net calls. ThomaTwo wrote:Everyone,Thank you for your help.

Powershell Microsoft.win32.registrykey Openremotebasekey Credentials

It turns out not to have been the computer name that was the problem - it was that the Windows Firewall was blocking communication on the computers that I was trying to access. I have been unable to determine which rule is causing the problem, but haven't managed that yet. However, I've written a rule to permit what I want on each server, so things are now good.doh! As I previously mentioned in the post about Get-Service, to check both the service and firewall rules, because they are disabled and blocked by default from VIsta and up.