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

Author Message
drewdog

  • Total Posts : 1
  • Scores: 0
  • Reward points : 0
  • Joined: 7/29/2010
  • Status: offline
VBS Script To Get PC's Information And Send To Excel Thursday, July 29, 2010 8:02 AM (permalink)
0
Hello All,
 
I did not write this script below. This works great for one PC but I need it to pull from a list of PCs in a text file. Can anyone help me please.
 
 
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"
 
#1
    k_quaid

    • Total Posts : 4
    • Scores: 0
    • Reward points : 0
    • Joined: 7/26/2010
    • Status: offline
    Re:VBS Script To Get PC's Information And Send To Excel Thursday, July 29, 2010 11:53 PM (permalink)
    0
    i have a script that creates folders from a list in a text file you could butcher the two together but i'm not sure how to only create one spreadsheet i think it would create a new excel file each time.

    ' NewFolder.vbs
    '
    ' Author k_quaid
    '
    ' Version 1.0 - 18/06/08
    ' ---------------------------------------------------------------'
    Option Explicit
    Dim objFSO, objFolder
    Set objFSO = CreateObject("Scripting.FileSystemObject")
    Const ForReading = 1
    Dim objDomain, fso, tsInputFile, strLine, arrInput
    Set fso = CreateObject("Scripting.FileSystemObject")
    Set tsInputFile = fso.OpenTextFile("textfile.txt", ForReading, False)
    While Not tsInputFile.AtEndOfStream
      strLine = tsInputFile.ReadLine
      arrInput = Split(strLine, ";")
    Set objFolder = objFSO.CreateFolder(arrInput(0))
    Wend
    tsInputFile.Close
    WScript.Echo "Finished"
    WScript.Quit(0)
     
    #2
      k_quaid

      • Total Posts : 4
      • Scores: 0
      • Reward points : 0
      • Joined: 7/26/2010
      • Status: offline
      Re:VBS Script To Get PC's Information And Send To Excel Friday, July 30, 2010 1:20 AM (permalink)
      0
      here you go, this is my first attempt, it does create a new Excel workbook each time but i'm sure there are clever people out there who can fix that alot quicker than i can.

      to test i exported a list of PC's from my AD but the script failed everytime it hit the first PC thatw as turned off

      Option Explicit
      Dim objFSO, objExcel, objWMIService, colItems, objItem
      Set objFSO = CreateObject("Scripting.FileSystemObject")
      Const ForReading = 1
      Dim objDomain, fso, tsInputFile, strLine, arrInput, strComputer
      Set fso = CreateObject("Scripting.FileSystemObject")
      Set tsInputFile = fso.OpenTextFile("customercare.txt", ForReading, False)
      While Not tsInputFile.AtEndOfStream
        strLine = tsInputFile.ReadLine
        arrInput = Split(strLine, ";")
       strComputer = arrInput(0)
       Scanpc (strComputer)
      Wend
      tsInputFile.Close
      WScript.Echo "Finished"
      WScript.Quit(0)
      Sub scanpc(strComputer)
      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"
      end Sub
       
      #3
        CØLLØSUS

        • Total Posts : 21
        • Scores: 2
        • Reward points : 0
        • Joined: 1/3/2011
        • Status: offline
        Re:VBS Script To Get PC's Information And Send To Excel Thursday, January 06, 2011 10:28 PM (permalink)
        0
        it works. check out my spammer
         
        #4

          Online Bookmarks Sharing: Share/Bookmark

          Jump to:

          Current active users

          There are 0 members and 1 guests.

          Icon Legend and Permission

          • New Messages
          • No New Messages
          • Hot Topic w/ New Messages
          • Hot Topic w/o New Messages
          • Locked w/ New Messages
          • Locked w/o New Messages
          • Read Message
          • Post New Thread
          • Reply to message
          • Post New Poll
          • Submit Vote
          • Post reward post
          • Delete my own posts
          • Delete my own threads
          • Rate post

          2000-2012 ASPPlayground.NET Forum Version 3.9