?
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
?
4,933 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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

My attempt to use PowerShell and other great resources found online to simplify the deployment of Office 365 ProPlus client components to any workstation that needs it, regardless of existing Office components that may be needing attention.
Auditing domain password hashes is a commonly overlooked but critical requirement to ensuring secure passwords practices are followed. Methods exist to extract hashes directly for a live domain however this article describes a process to extract u…
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…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…

752 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