• Welcome to Tux Reports: Where Penguins Fly. We hope you find the topics varied, interesting, and worthy of your time. Please become a member and join in the discussions.

VBS Script To Get PC's Information And Send To Excel

D

drewdog1977

Flightless Bird
Hello all,

I found this script and it works great for one PC but I need it to pull from a list of PC's in a text file. Can anyone help me with this?


strComputer = InputBox ("Enter Machine Name")



Set objExcel = CreateObject("Excel.Application")

objExcel.Visible = True

objExcel.Workbooks.Add



objExcel.Cells(1, 1).Value = "Name"

objExcel.Cells(2, 1).Value = "Caption"

objExcel.Cells(3, 1).Value = "Version"

objExcel.Cells(4, 1).Value = "Registered User"

objExcel.Cells(5, 1).Value = "Serial Number"

objExcel.Cells(6, 1).Value = "CSD Version"

objExcel.Cells(7, 1).Value = "Description"

objExcel.Cells(8, 1).Value = "Last Boot Up Time"

objExcel.Cells(9, 1).Value = "Local Date Time"

objExcel.Cells(10, 1).Value = "Organization"

objExcel.Cells(11, 1).Value = "Domain"

objExcel.Cells(12, 1).Value = "Manufacturer"

objExcel.Cells(13, 1).Value = "Model"

objExcel.Cells(14, 1).Value = "Number Of Processors"

objExcel.Cells(15, 1).Value = "Primary Owner Name"

objExcel.Cells(16, 1).Value = "System Type"

objExcel.Cells(17, 1).Value = "Total Physical Memory"

objExcel.Cells(18, 1).Value = "User Name"

objExcel.Cells(19, 1).Value = "Caption"

objExcel.Cells(20, 1).Value = "Manufacturer"

objExcel.Cells(21, 1).Value = "Name"

objExcel.Cells(22, 1).Value = "Release Date"

objExcel.Cells(23, 1).Value = "Serial Number"

objExcel.Cells(24, 1).Value = "SMBIOS BIOS Version"

objExcel.Cells(25, 1).Value = "Version"



Set objWMIService = GetObject("winmgmts:/\" & strComputer & "\root\cimv2")

Set colItems = objWMIService.ExecQuery("Select * from Win32_OperatingSystem")

For Each objItem in colItems



objExcel.Cells(1, 2).Value = objItem.CSName

objExcel.Cells(2, 2).Value = objItem.Caption

objExcel.Cells(3, 2).Value = objItem.Version

objExcel.Cells(4, 2).Value = objItem.RegisteredUser

objExcel.Cells(5, 2).Value = objItem.SerialNumber

objExcel.Cells(6, 2).Value = objItem.CSDVersion

objExcel.Cells(7, 2).Value = objItem.Description

objExcel.Cells(8, 2).Value = objItem.LastBootUpTime

objExcel.Cells(9, 2).Value = objItem.LocalDateTime

objExcel.Cells(10, 2).Value = objItem.Organization

Next



Set colItems = objWMIService.ExecQuery("Select * from Win32_ComputerSystem")

For Each objItem in colItems



objExcel.Cells(11, 2).Value = objItem.Domain

objExcel.Cells(12, 2).Value = objItem.Manufacturer

objExcel.Cells(13, 2).Value = objItem.Model

objExcel.Cells(14, 2).Value = objItem.NumberOfProcessors

objExcel.Cells(15, 2).Value = objItem.PrimaryOwnerName

objExcel.Cells(16, 2).Value = objItem.SystemType

objExcel.Cells(17, 2).Value = (objItem.TotalPhysicalMemory /1024) & " MB"

objExcel.Cells(18, 2).Value = objItem.UserName

Next



Set objWMIService = GetObject("winmgmts:/\" & strComputer & "\root\cimv2")

Set colItems = objWMIService.ExecQuery("Select * from Win32_BIOS")

For Each objItem in colItems

objExcel.Cells(19, 2).Value = objItem.Caption

objExcel.Cells(20, 2).Value = objItem.Manufacturer

objExcel.Cells(21, 2).Value = objItem.Name

objExcel.Cells(22, 2).Value = objItem.ReleaseDate

objExcel.Cells(23, 2).Value = objItem.SerialNumber

objExcel.Cells(24, 2).Value = objItem.SMBIOSBIOSVersion

objExcel.Cells(25, 2).Value = objItem.Version

Next



objExcel.Range("A1:A25").Select

objExcel.Selection.Font.ColorIndex = 11

objExcel.Selection.Font.Bold = True

objExcel.Cells.EntireColumn.AutoFit



MsgBox "Done"
 
P

Pegasus [MVP]

Flightless Bird
"undisclosed" wrote in message
news:376d7d4acf0f90f161a7862e7fab2c34@nntp-gateway.com...
>
> Hello all,
>
> I found this script and it works great for one PC but I need it to pull
> from a list of PC's in a text file. Can anyone help me with this?
>
>
> strComputer = InputBox (\"Enter Machine Name\")
>
>
>
> Set objExcel = CreateObject(\"Excel.Application\")
>
> objExcel.Visible = True
>
> objExcel.Workbooks.Add
>
>
>
> objExcel.Cells(1, 1).Value = \"Name\"
>
> objExcel.Cells(2, 1).Value = \"Caption\"
>
> objExcel.Cells(3, 1).Value = \"Version\"
>
> objExcel.Cells(4, 1).Value = \"Registered User\"
>
> objExcel.Cells(5, 1).Value = \"Serial Number\"
>
> objExcel.Cells(6, 1).Value = \"CSD Version\"
>
> objExcel.Cells(7, 1).Value = \"Description\"
>
> objExcel.Cells(8, 1).Value = \"Last Boot Up Time\"
>
> objExcel.Cells(9, 1).Value = \"Local Date Time\"
>
> objExcel.Cells(10, 1).Value = \"Organization\"
>
> objExcel.Cells(11, 1).Value = \"Domain\"
>
> objExcel.Cells(12, 1).Value = \"Manufacturer\"
>
> objExcel.Cells(13, 1).Value = \"Model\"
>
> objExcel.Cells(14, 1).Value = \"Number Of Processors\"
>
> objExcel.Cells(15, 1).Value = \"Primary Owner Name\"
>
> objExcel.Cells(16, 1).Value = \"System Type\"
>
> objExcel.Cells(17, 1).Value = \"Total Physical Memory\"
>
> objExcel.Cells(18, 1).Value = \"User Name\"
>
> objExcel.Cells(19, 1).Value = \"Caption\"
>
> objExcel.Cells(20, 1).Value = \"Manufacturer\"
>
> objExcel.Cells(21, 1).Value = \"Name\"
>
> objExcel.Cells(22, 1).Value = \"Release Date\"
>
> objExcel.Cells(23, 1).Value = \"Serial Number\"
>
> objExcel.Cells(24, 1).Value = \"SMBIOS BIOS Version\"
>
> objExcel.Cells(25, 1).Value = \"Version\"
>
>
>
> Set objWMIService = GetObject(\"winmgmts:/\\" & strComputer &
> \"\root\cimv2\")
>
> Set colItems = objWMIService.ExecQuery(\"Select * from
> Win32_OperatingSystem\")
>
> For Each objItem in colItems
>
>
>
> objExcel.Cells(1, 2).Value = objItem.CSName
>
> objExcel.Cells(2, 2).Value = objItem.Caption
>
> objExcel.Cells(3, 2).Value = objItem.Version
>
> objExcel.Cells(4, 2).Value = objItem.RegisteredUser
>
> objExcel.Cells(5, 2).Value = objItem.SerialNumber
>
> objExcel.Cells(6, 2).Value = objItem.CSDVersion
>
> objExcel.Cells(7, 2).Value = objItem.Description
>
> objExcel.Cells(8, 2).Value = objItem.LastBootUpTime
>
> objExcel.Cells(9, 2).Value = objItem.LocalDateTime
>
> objExcel.Cells(10, 2).Value = objItem.Organization
>
> Next
>
>
>
> Set colItems = objWMIService.ExecQuery(\"Select * from
> Win32_ComputerSystem\")
>
> For Each objItem in colItems
>
>
>
> objExcel.Cells(11, 2).Value = objItem.Domain
>
> objExcel.Cells(12, 2).Value = objItem.Manufacturer
>
> objExcel.Cells(13, 2).Value = objItem.Model
>
> objExcel.Cells(14, 2).Value = objItem.NumberOfProcessors
>
> objExcel.Cells(15, 2).Value = objItem.PrimaryOwnerName
>
> objExcel.Cells(16, 2).Value = objItem.SystemType
>
> objExcel.Cells(17, 2).Value = (objItem.TotalPhysicalMemory /1024) & \"
> MB\"
>
> objExcel.Cells(18, 2).Value = objItem.UserName
>
> Next
>
>
>
> Set objWMIService = GetObject(\"winmgmts:/\\" & strComputer &
> \"\root\cimv2\")
>
> Set colItems = objWMIService.ExecQuery(\"Select * from Win32_BIOS\")
>
> For Each objItem in colItems
>
> objExcel.Cells(19, 2).Value = objItem.Caption
>
> objExcel.Cells(20, 2).Value = objItem.Manufacturer
>
> objExcel.Cells(21, 2).Value = objItem.Name
>
> objExcel.Cells(22, 2).Value = objItem.ReleaseDate
>
> objExcel.Cells(23, 2).Value = objItem.SerialNumber
>
> objExcel.Cells(24, 2).Value = objItem.SMBIOSBIOSVersion
>
> objExcel.Cells(25, 2).Value = objItem.Version
>
> Next
>
>
>
> objExcel.Range(\"A1:A25\").Select
>
> objExcel.Selection.Font.ColorIndex = 11
>
> objExcel.Selection.Font.Bold = True
>
> objExcel.Cells.EntireColumn.AutoFit
>
>
>
> MsgBox \"Done\"
>
>
> --
> drewdog1977


Here you go:

sList = "d:/temp\PCs.txt" 'This file contains all PC names
Set oFSO = CreateObject("Scripting.FileSystemObject")
aList = Split(oFSO.OpenTextFile(sList).ReadAll, VbCrLf)
For Each sName In aList
GetDetails(sName)
Next

Sub GetDetails(strComputer)
' Paste your code here
End Sub

You actually posted your query in the wrong newsgroup. Try
Microsoft.Public.Scripting.VBScript for your next VB-Script related
question. Note also that you have lots of backslashes in places where you
cannot have them under the rules of VB Script.
 
Top