Dontbyteme
IS-IT--Management
I have a script that looks at a computerList.txt file, query's each ComputerName listed in the txt file for information and then outputs all that information in 1 txt file. What I'd like to do is have the information output into separate txt files, 1 file for each ComputerName (ComputerName.txt). Here is my code
Code:
'File name for remote system results
'strComputer= "computerInfo2"
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.CreateTextFile("ComputerInfoList.txt", True)
Set objComputerlist = objFSO.OpenTextFile("C:\Users\username.adm\Documents\PatchScriptTest\ComputerListTest.txt", 1)
On Error Resume Next
'Query network PC's for information
Do Until objComputerlist.AtEndOfStream
strComputer = objComputerlist.ReadLine
Set objGroup = GetObject("" & strComputer)
For Each objMember In objGroup.Members
Set wmi = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
objFile.WriteLine "Today is:" & FormatDateTime(Now,0)
objFile.WriteLine "Computer:" & strComputer
objFile.WriteLine "Serial Number: " & objSMBIOS.SerialNumber
'Find serial number
Set colSMBIOS = wmi.ExecQuery("Select * from Win32_SystemEnclosure")
For Each objSMBIOS in colSMBIOS
objFile.WriteLine "Serial Number: " & objSMBIOS.SerialNumber
Next
'Find MAC & IP
Set IPConfigSet = wmi.ExecQuery("Select * from Win32_NetworkAdapterConfiguration where IPEnabled=True")
For Each IPConfig in IPConfigSet
objFile.WriteLine "IP Address: " & Join(IPConfig.IPAddress,"|")
objFile.WriteLine "MAC Address: " & IPConfig.MACAddress
Next
'Query system to installed KB's
oTS.WriteLine "INSTALLED HOTFIXES"
Set colItems = wmi.ExecQuery("Select * from Win32_QuickFixEngineering")
For Each objItem in colItems
objFile.WriteLine "" & objItem.HotFixID
Next
'Print out list of installed software
objFile.WriteLine
objFile.WriteLine "INSTALLED SOFTWARE"
objFile.WriteLine
'Query system for installed software
Set colItems = objWMIService.ExecQuery("Select * from Win32_Product")
For Each objItem in colItems
objFile.WriteLine "Caption: " & objItem.Caption
objFile.WriteLine "Version: " & objItem.Version
objFile.WriteLine "Description: " & objItem.Description
objFile.WriteLine
Next
Next
Loop