Script to gather registry value from remote computers

Need a script to check what is the registry value and get the out put in an text or excel format.
I need to run this script remotely on 2000+ server and get the output in one single file.
LVL 2
NaheerAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Dan McFaddenSystems EngineerCommented:
Can you post the reg key?

Dan
NaheerAuthor Commented:
HKEY_LOCAL_MACHINE\SOFTWARE\XYZ\1 this is the location of the registry value and on the right hand side there is a string with the name "PatchGroup" i need that value
Bill PrewIT / Software Engineering ConsultantCommented:
How will the 2000+ servers be identified, do you have a list of them in a text file, or need to search AD, etc?

~bp
Your Guide to Achieving IT Business Success

The IT Service Excellence Tool Kit has best practices to keep your clients happy and business booming. Inside, you’ll find everything you need to increase client satisfaction and retention, become more competitive, and increase your overall success.

Sudeep SharmaTechnical DesignerCommented:
Create a batch file and include the following line in it. This would give you what is inside the PatchGroup
REG QUERY HKEY_LOCAL_MACHINE\SOFTWARE\XYZ\1p /v PatchGroup

To redirect the output of the same to a text file modify the command to the following:
REG QUERY HKEY_LOCAL_MACHINE\SOFTWARE\XYZ\1p /v PatchGroup > C:\reg_result.txt

You could change the name of the output file to what ever you like.

Run the batch in logon script or through Group Policy.

You could also redirect the output to the a single file on the remote server, for that the command would change slightly.
REG QUERY HKEY_LOCAL_MACHINE\SOFTWARE\XYZ\1p /v PatchGroup >> \\DC\SharedFolder\reg_result.txt

There are other ways of doing it like Powershell.

Thanks,
Sudeep

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
NaheerAuthor Commented:
How to run it against the 2000+ server there should be some file which will be calling these servers.

I have the server list handy.
Dan McFaddenSystems EngineerCommented:
Here's your script:

$ServerList = Get-Content ServerList.txt
$RegBasePath = "LocalMachine"
$RegSubKey = "SOFTWARE\XYZ\1"
$RegStringName = "PatchGroup"
$OutputFile = "ServerRegKey.csv"
$Output = @()

foreach ($server in $ServerList)
{
  Write-Host "Working on server::  " $server
  $Hive = [Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey($RegBasePath, $server)
  $RegKey = $Hive.OpenSubKey($RegSubKey)
  $StringValue = $RegKey.GetValue($RegStringName)
  
  $rinfo = New-Object PSObject
  $rinfo | Add-Member -MemberType NoteProperty -Name  "Server" -Value $server
  $rinfo | Add-Member -MemberType NoteProperty -Name  "Registry-BasePath" -Value ($RegBasePath)
  $rinfo | Add-Member -MemberType NoteProperty -Name  "Registry-SubKey" -Value ($RegSubKey)
  $rinfo | Add-Member -MemberType NoteProperty -Name  "Registry-String" -Value ($RegStringName)
  $rinfo | Add-Member -MemberType NoteProperty -Name  "Registry-Value" -Value ($StringValue)
  $Output += $rinfo
}

$Output | Export-Csv $OutputFile  -NoTypeInformation -UseCulture

Open in new window


1. The script file and the server list file should reside in the same directory
2. The file with the server names in it should be called "ServerList.txt"
3. The script variables at the top of the script can be adjusted to handle any registry location
4. The output file is written to the same directory the script is in

Dan
NaheerAuthor Commented:
Thanks Dan I see the script provided is Powershell but i have some 2003 and 200 server also where is can't run this script can you please provide it in VB or batch file.
Dan McFaddenSystems EngineerCommented:
You could use the batch that Sudeep posted above.  Would seem to fit your needs.

Dan
Bob McCoyCommented:
In the future please pick a more meaningful thread title.  "Script" does not help.  Perhaps "Search for registry key on multiple servers" would have been better.

The experts here are all volunteers.  And it makes it easier for all of us to skim titles to see if it's an area we have interest or expertise in.
NaheerAuthor Commented:
As I have mixed environment I wanted kind of vbscript
I had some manual work. Script reduced my work 90 %.

Thanks for you solution
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Programming

From novice to tech pro — start learning today.