Re: Send VBScript Output to an Excel Spreadsheet
- From: "LakeGator" <LakeGator@xxxxxxxxx>
- Date: 21 Nov 2005 08:51:43 -0800
You already have virtually everything. All you need to do is to add
the values in row 2. Below is your script with row 2 populated right
behind each of your echo statements:
'This script returns various computer information including computer
'name, serial number, make & model, os version and service pack level,
'as well as various other useful pieces of information.
Set objExcel = CreateObject("Excel.Application")
objExcel.Visible = True
objExcel.Workbooks.Add
objExcel.Cells(1, 1).Value = "OS Version"
objExcel.Cells(1, 2).Value = "Service Pack"
objExcel.Cells(1, 3).Value = "# of Procs"
objExcel.Cells(1, 4).Value = "Proc Type"
objExcel.Cells(1, 5).Value = "Max Clock Speed"
objExcel.Cells(1, 6).Value = "Tot Phy Mem"
objExcel.Cells(1, 7).Value = "Free Phy Mem"
objExcel.Cells(1, 8).Value = "Tot Virtual Mem"
objExcel.Cells(1, 9).Value = "Free Virtual Mem"
objExcel.Cells(1, 10).Value = "Tot Visible Mem"
objExcel.Cells(1, 11).Value = "Domain"
objExcel.Cells(1, 12).Value = "Domain Role"
objExcel.Cells(1, 13).Value = "Manufacturer"
objExcel.Cells(1, 14).Value = "Model"
objExcel.Cells(1, 15).Value = "Serial Number"
objExcel.Cells(1, 16).Value = "User"
strComputers = InputBox _
("What computer would you like info on?", _
"SECO Inventory Analzyer v1.0", strLocalComputer)
On Error Resume Next
Set objNetwork = CreateObject("Wscript.Network")
strLocalComputer = objNetwork.ComputerName
If strComputers = "" Then
Wscript.Quit
End If
arrComputers = Split(strComputers, " ")
For Each strComputer in arrComputers
'
=====================================================================
' Insert your code here
'
=====================================================================
Set objWMIService = GetObject _
("winmgmts:\\" & strComputer & "\root\cimv2")
Set colItems = objWMIService.ExecQuery _
("Select * From Win32_OperatingSystem")
For Each objItem in ColItems
Wscript.Echo strComputer & ": " & objItem.Caption
objExcel.Cells(2, 1).Value = objItem.Caption
Next
Set colOSes = objWMIService.ExecQuery("Select * from
Win32_OperatingSystem")
For Each objOS in colOSes
WScript.Echo "Service Pack: " & objOS.ServicePackMajorVersion & "." &
_
objOS.ServicePackMinorVersion
objExcel.Cells(2, 2).Value = objOS.ServicePackMajorVersion & "." & _
objOS.ServicePackMinorVersion
Next
Set objWMIService = GetObject("winmgmts:\\" & strComputer &
"\root\CIMV2")
Set colCSes = objWMIService.ExecQuery("SELECT * FROM
Win32_ComputerSystem")
For Each objCS In colCSes
WScript.Echo "Number Of Processors: " & objCS.NumberOfProcessors
objExcel.Cells(2, 3).Value = objCS.NumberOfProcessors
Next
Set colProcessors = objWMIService.ExecQuery("Select * from
Win32_Processor")
For Each objProcessor in colProcessors
WScript.Echo "Name: " & objProcessor.Name
WScript.Echo "Maximum Clock Speed: " & objProcessor.MaxClockSpeed
objExcel.Cells(2, 4).Value = objProcessor.Name
objExcel.Cells(2, 5).Value = objProcessor.MaxClockSpeed
Next
Set objWMIService = GetObject("winmgmts:\\" & strComputer &
"\root\CIMV2")
Set colCSItems = objWMIService.ExecQuery("SELECT * FROM
Win32_ComputerSystem")
For Each objCSItem In colCSItems
WScript.Echo "Total Physical Memory: " &
objCSItem.TotalPhysicalMemory
objExcel.Cells(2, 6).Value = objCSItem.TotalPhysicalMemory
Next
Set colOSItems = objWMIService.ExecQuery("SELECT * FROM
Win32_OperatingSystem")
For Each objOSItem In colOSItems
WScript.Echo "Free Physical Memory: " & objOSItem.FreePhysicalMemory
WScript.Echo "Total Virtual Memory: " &
objOSItem.TotalVirtualMemorySize
WScript.Echo "Free Virtual Memory: " & objOSItem.FreeVirtualMemory
WScript.Echo "Total Visible Memory Size: " &
objOSItem.TotalVisibleMemorySize
objExcel.Cells(2, 7).Value = objOSItem.FreePhysicalMemory
objExcel.Cells(2, 8).Value = objOSItem.TotalVirtualMemorySize
objExcel.Cells(2, 9).Value = objOSItem.FreeVirtualMemory
objExcel.Cells(2, 10).Value = objOSItem.TotalVisibleMemorySize
Next
Set objWMIService = GetObject("winmgmts:\\" & strComputer &
"\root\CIMV2")
Set colItems = objWMIService.ExecQuery("SELECT * FROM
Win32_ComputerSystem")
For Each objItem In colItems
WScript.Echo "Domain: " & objItem.Domain
objExcel.Cells(2, 11).Value = objItem.Domain
Select Case objItem.DomainRole
Case 0 strDomainRole = "Standalone Workstation"
Case 1 strDomainRole = "Member Workstation"
Case 2 strDomainRole = "Standalone Server"
Case 3 strDomainRole = "Member Server"
Case 4 strDomainRole = "Backup Domain Controller"
Case 5 strDomainRole = "Primary Domain Controller"
End Select
WScript.Echo "Domain Role: " & strDomainRole
objExcel.Cells(2, 12).Value = strDomainRole
strRoles = Join(objItem.Roles, ",")
Next
Set objWMIService = GetObject("winmgmts:\\" & strComputer &
"\root\CIMV2")
Set colItems = objWMIService.ExecQuery("SELECT * FROM
Win32_ComputerSystem")
For Each objItem In colItems
WScript.Echo "Manufacturer: " & objItem.Manufacturer
WScript.Echo "Model: " & objItem.Model
objExcel.Cells(2, 13).Value = objItem.Manufacturer
objExcel.Cells(2, 14).Value = objItem.Model
Next
Set dtmConvertedDate = CreateObject("WbemScripting.SWbemDateTime")
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer &
"\root\cimv2")
Set colOperatingSystems = objWMIService.ExecQuery _
("Select * from Win32_OperatingSystem")
For Each objOperatingSystem in colOperatingSystems
Wscript.Echo "Serial Number: " & objOperatingSystem.SerialNumber
objExcel.Cells(2, 15).Value = objOperatingSystem.SerialNumber
Next
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer &
"\root\cimv2")
Set colComputer = objWMIService.ExecQuery _
("Select * from Win32_ComputerSystem")
For Each objComputer in colComputer
Wscript.Echo "Logged-on user: " & objComputer.UserName
objExcel.Cells(2, 16).Value = objComputer.UserName
Next
Next
.
- Follow-Ups:
- References:
- Re: Send VBScript Output to an Excel Spreadsheet
- From: Mike
- Re: Send VBScript Output to an Excel Spreadsheet
- From: LakeGator
- Re: Send VBScript Output to an Excel Spreadsheet
- From: Mike
- Re: Send VBScript Output to an Excel Spreadsheet
- Prev by Date: Re: Event Log Scripting
- Next by Date: Re: sending attachment using variable
- Previous by thread: Re: Send VBScript Output to an Excel Spreadsheet
- Next by thread: Re: Send VBScript Output to an Excel Spreadsheet
- Index(es):
Relevant Pages
|