Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

vbs script to read registry values on remote computers and write the results in a csv or txt file

Posted on 2014-02-18
4
Medium Priority
?
5,117 Views
Last Modified: 2014-02-18
I like this script below but instead of having to type the machine name one at a time with strComputer = InputBox("Enter the Name of the Remote PC: ")
I would like to just put all of my servers in a txt file and have it run this script against all servers in the list



' Set the constants
Const HKEY_LOCAL_MACHINE = &H80000002
Const ForAppending = 8

' Create FileSystemObject
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objTextFile = objFSO.OpenTextFile _
    ("c:\temp\environment_variables.txt", ForAppending, True)


strComputer = InputBox("Enter the Name of the Remote PC: ")
 
Set oReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & _
    strComputer & "\root\default:StdRegProv")

objTextFile.WriteLine("PC Name: " & strComputer)
 
strKeyPath = "Software\SYMANTEC\Symantec Endpoint Protection\SMC"
strValueName = "ProductVersion"
oReg.GetStringValue HKEY_LOCAL_MACHINE,strKeyPath,strValueName,strValue
'Wscript.Echo "Current ProducVersion Value: " & strValue
objTextFile.WriteLine("Current ProductVersion Value: " & strValue)
 
 


objTextFile.WriteLine(vbCrLf)

objTextFile.Close
0
Comment
Question by:scriptz
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
4 Comments
 
LVL 67

Accepted Solution

by:
sirbounty earned 2000 total points
ID: 39868868
A simple loop should do the trick...

' Set the constants
Const HKEY_LOCAL_MACHINE = &H80000002
Const ForAppending = 8

' Create FileSystemObject
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.OpenTextFile ("c:\temp\environment_variables.txt", ForAppending, True)

arrComputers = Split(objFSO.OpenTextFile("c:\temp\myComputers.txt").ReadAll, vbNewLine)

for each strComputer in arrComputers
  wscript.echo "Examining " & strComputer
  Set oReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\default:StdRegProv")
  objFile.WriteLine "PC Name: " & strComputer
 
  strKeyPath = "Software\SYMANTEC\Symantec Endpoint Protection\SMC"
  strValueName = "ProductVersion"
  oReg.GetStringValue HKEY_LOCAL_MACHINE,strKeyPath,strValueName,strValue
  'Wscript.Echo "Current ProducVersion Value: " & strValue
  objFile.WriteLine("Current ProductVersion Value: " & strValue)
  objFile.WriteLine(vbCrLf)
next 

objFile.Close

Open in new window

0
 
LVL 67

Expert Comment

by:sirbounty
ID: 39868876
Your source text file should contain a single computer name on each line of the file:

computer1
computer2
[etc]
0
 

Author Closing Comment

by:scriptz
ID: 39869037
This is exactly what I was looking for. Thanks
0
 
LVL 67

Expert Comment

by:sirbounty
ID: 39869121
Happy to help - thanks for the grade! :^)
0

Featured Post

Veeam Task Manager for Hyper-V

Task Manager for Hyper-V provides critical information that allows you to monitor Hyper-V performance by displaying real-time views of CPU and memory at the individual VM-level, so you can quickly identify which VMs are using host resources.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this post we will be converting StringData saved within a text file into a hash table. This can be further used in a PowerShell script for replacing settings that are dynamic in nature from environment to environment.
There are times when we need to generate a report on the inbox rules, where users have set up forwarding externally in their mailbox. In this article, I will be sharing a script I wrote to generate the report in CSV format.
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the adminiā€¦
Screencast - Getting to Know the Pipeline

610 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question