Quantcast
Channel: The Official Scripting Guys Forum! forum
Viewing all articles
Browse latest Browse all 15028

Reg Query and OpenRemotebaseKey

$
0
0

Hey everyone,

I have been trying to set up a script that would check the registry Uninstall branch for certain programs listed and have been failing with the same error messages each time. The script is supposed to take computer names from a CSV file and check them remotely, but it doesn't go anywhere past local resources.

I continuously get this error message on this string of the code.

$registry= [Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey([Microsoft.Win32.RegistryHive]::localmachine,$computers)

 

Exception calling "OpenRemoteBaseKey" with "2" argument(s): "Not enough resources are available to complete this operation.
"
At C:\Scripts\Computer Name.ps1:31 char:3
+         $registry= [Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey([Microsoft.Win32.R ...
+    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
    + FullyQualifiedErrorId : IOException

Exception calling "OpenRemoteBaseKey" with "2" argument(s): "Not enough resources are available to complete this operation.
"
At C:\Scripts\Computer Name.ps1:33 char:3
+         $registry= [microsoft.win32.registrykey]::OpenRemoteBaseKey('localmachine',$co ...
+    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
    + FullyQualifiedErrorId : IOException

I'm not sure what I could be missing or what I am doing wrong. I'm pretty new to this and am just experimenting for a side project and would really appreciate some insight on this.

i have also tried the REG QUERY to look in the HKLM with the whole path to the sub branch listed

$SubBranch="SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall

This is what I have that works on my local machine

REG QUERY HKLM\SOFTWARE\microsoft\windows\currentversion\uninstall /s

Although when I try to enter another machine it comes back with an error

PS C:\Windows\system32> REG QUERY

\\"ComputerName"\HKLM\SOFTWARE\microsoft\windows\currentversion\uninstall /s

ERROR: Not enough resources are available to complete this operation.

Does it mean that I don't have permission to query over the network? Or is there something else I need to enable on a remote computer? Should I run the PS module as 3 or 2 ? Is there a way I need to structure the query to pull another resource from the computer?

Any help would be really appreciated!



Viewing all articles
Browse latest Browse all 15028

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>