Maybe this help you:
http://code.msdn.microsoft.com/PSRemoteRegistry
Example:
Get-RegValue -ComputerName “10.10.10.2” -Key "SYSTEM\CurrentControlSet\Control\Terminal Server" -Value fDenyTSConnections
If don't exists then return nothing.
Hi
I had to do something similar have a look at my code here … http://gallery.technet.microsoft.com/scriptcenter/8b49a002-f051-4014-99d7-33fc4b80c35e
Basically using [Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey and enumerating all the values beneath it to find a key with certain values in it.
Hope it helps.
J
Hi,
Thanks for posting in Microsoft TechNet forums.
Based on my research, try the following sample powershell script:
$host = “RemoteComputer”
$Hive = [Microsoft.Win32.RegistryHive]“LocalMachine”;
$regKey = [Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey($Hive,$host);
$ref = $regKey.OpenSubKey(“SOFTWARE\Microsoft\windows\CurrentVersion\Uninstall”);
if (!$ref) {$false}
else {$true}
Resource:
Check for remote registry existance with Powershell
http://techibee.com/sysadmins/check-for-remote-registry-existance-with-powershell/265
Best Regards
Dale Qiao
TechNet Subscriber Support in forum. If you have any feedback on our support, please contact
tngfb@microsoft.com
The PSRemoteRegistry has two test functions you can use:
Test-RegKey and Test-RegValue
You can download it from here:
http://code.msdn.microsoft.com/PSRemoteRegistry
Going through the Script this morning and I was having some problems with it. I have found that $host is a constant, Here is the changed script for those that follow.
# Script to verify the existance of a Registry Key on Remote Machines $remoteComputer= "DevelopmentMachine" $regkey = [Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey([Microsoft.Win32.RegistryHive]::LocalMachine, $remoteComputer) $ref = $regKey.OpenSubKey("SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall"); if (!$ref) {$false} else {$true}
Correct, $host is an automatic variable. It is created and maintained by Windows PowerShell.
I'm reading the registry in this same way. my script works on one win serv 2k8 r2 box, but not another. when it fails on this other win 2k8 box i get:
Exception calling "OpenRemoteBaseKey" with "2" argument(s): "The network path was not found.
"
At C:\Users\myprofile\AppData\Local\Temp\7a9e6036-9a2b-49aa-aa42-7157a933e148.ps1:43 char:65
+ $ProductName = ([Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey <<<< ('LocalMachine', $hostname).OpenSubKey('SOFTWARE\Microsoft\Windows NT\Cu
rrentVersion').GetValue('ProductName'))
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : DotNetMethodException
Any ideas as to why it errors with the above on one win2k8r2 box, and not on the other?
Thanks
This means that the remoteregistry service is stopped.
You can enable this by group policy, or earlier on in the script run this command:
Get-Service -ComputerName $computer -Name RemoteRegistry |Start-Service
(where $computer is the name of the computer)
Yes this really means that RemoteRegistry is stopped or Disabled.
So use below sequence to set it automatic or manual (This example set it to automatic) and then start it :
$computer= "Hostname of Remote machine"
Set-Service -ComputerName $computer -Name RemoteRegistry -StartupType Automatic
Get-Service -ComputerName $computer -Name RemoteRegistry | Start-Service
(First command line is about the hostname of the computer you are targetting)
Thanks to all for contribution.
Hi Stejo,
You can use below command in powershell.
sc.exe \\XX.XX.XX.XX start "RemoteRegistry"
where XX.XX.XX.XX system IP.