1

I am trying to get a registry value from a remote machine but everything I have tried did not work.

Both machines are running windows 7 x64, they are on the same domain, firewall off, powershell 4.0

when I run :

$reg = [Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey("LocalMachine", "APPS-EUAUTO1")
$key = $reg.OpenSubkey('SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion')
Write-Host $key.GetValue('InstallDate')

i get

Exception calling "OpenRemoteBaseKey" with "2" argument(s): "The network path was not found.
"
At C:\Users\User\Desktop\test.ps1:1 char:1
+ $reg = [Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey("LocalMachine", "APPS-EU ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : IOException

I know nothing of .Net and I have only played with PowerShell for the last month. I have also tried the module PSRemoteRegistry and when I am using Get-RegValue I get the same error message (I think it is using the same thing)

Ionut
  • 1,729
  • 4
  • 23
  • 50

1 Answers1

4

Assuming you can ping APPS-EUAUTO1(and it resolves to correct IP) and firewall is off.. make sure Remote Registry service is running on your APPS-EUAUTO1

Raf
  • 9,681
  • 1
  • 29
  • 41
  • 1
    Yes, starting the _Remote Registry_ service did it. Is there any way to start this service remotely ? – Ionut Apr 17 '14 at 13:44
  • I mean do it with PowerShell, because I found a way from command prompt `sc \\APPS-EUAUTO1 start "RemoteRegistry"` – Ionut Apr 17 '14 at 13:54
  • If you have WinRM enabled(http://technet.microsoft.com/en-us/magazine/ff700227.aspx) you can run `invoke-command -computerName APPS-EUAUTO1 -scriptBlock { start-service RemoteRegistry }`. To use remote WMI you need _Remote Registry_ to be running in first place. PSExec could be another(non-Powershell) solution. – Raf Apr 17 '14 at 14:00
  • Thanks, I will use `sc.exe \\APPS-EUAUTO1 start "RemoteRegistry"` in PowerShell – Ionut Apr 17 '14 at 15:40