Link to home
Start Free TrialLog in
Avatar of joukiejouk
joukiejouk

asked on

Need help to run a query via PSEXEC to look for a registry key and export the result to a text file.

Need help to run a query via PSEXEC . I've been tasked to do the following:

John's request:




Bill's response (A network admin):





I am the system admin who need to complete task above but do not have strong skills in scripting. If I can come up with something via PSEXEC, that would be great. If there's a better approach, fill me in. Using the scenario/example above, can someone help me write a script via PSEXEC?
Avatar of serialband
serialband
Flag of Ukraine image

Would it would be easier to use reg.exe query?  http://www.robvanderwoude.com/regsearch.php

REG Query HKLM\Software\Microsoft\Windows\CurrentVersion\Uninstall\{901......xxxxxx} /v Displayname \\Computer_Name
Since you made a picture instead of cutting and pasting the string, I'm not going to try and eyeball it and type that out.  You can figure it out yourself.

Put that in a for loop
for %i in (computer1, computer2, computer.) DO  REG Query HKLM\Software\Microsoft\Windows\CurrentVersion\Uninstall\{901......xxxxxx} /v Displayname \\%i

Open in new window


If your have name in numerical sequence:
for /l in %i in (1,1,99)  DO REG Query HKLM\Software\Microsoft\Windows\CurrentVersion\Uninstall\{901......xxxxxx} /v Displayname \\Computer%i

Open in new window

Avatar of joukiejouk
joukiejouk

ASKER

Dont I need to put abc.com somewhere in the script?  I want to run the command against our AD to look for all machines that might have that regisry key.

Here is what I am getting when i ran your command.

User generated image
Here is the string if you need to use it for the command:

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{90150000-008F-0000-1000-0000000FF1CE}
Sorry I misread the syntax.
It should be:

for %i in (computer1, computer2, computer3) DO  REG Query \\%i\HKLM\Software\Microsoft\Windows\CurrentVersion\Uninstall\{90150000-008F-0000-1000-0000000FF1CE} /v Displayname 

Open in new window


for /l in %i in (1,1,99)  DO REG Query \\computer%i\HKLM\Software\Microsoft\Windows\CurrentVersion\Uninstall\{90150000-008F-0000-1000-0000000FF1CE} /v Displayname 

Open in new window

How would I run this query against a domain controller (e.g. - abc.com)  or a certain OU? Let's say the OU is (e.g. - TEST).  I need to query all machines within the domain. That is the challenge. Can you share the command given the scenario as mentioned?
Any Expert have any other suggestion?
I wish experts exchange was more consistent with their notification emails.  They keep changing them and I missed the responses.


You don't need to be on the domain controller.  You just need to run it with an admin account that has Local administrator privileges.  

As for getting computers, you would run powershell.
$ou = "OU=Workstations,OU=Computers,DC=MyDomain,DC=com"
$Computers = Get-ADComputer -Filter '*' -SearchBase $ou
$Computers | Foreach { $_.DNSHostName } | Out-File -Filepath "output.txt"
Did this ever work out for you?
This question needs an answer!
Become an EE member today
7 DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform.
View membership options
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.