none
Script para mostrar modelo número de série do equipamento RRS feed

  • Pergunta

  • Boa noite!
    Eu preciso criar um inventário de todos os desktops empresarial contendo modelo e número de série do equipamento. Atualmente estou usando o script abaixo:


    On Error Resume Next 
    Dim strComputer
    
    strComputer = InputBox("Enter the name of the computer:") 
    Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2") 
    
    Set colSettings = objWMIService.ExecQuery("Select * from Win32_ComputerSystem")
    
    For Each objComputer in colSettings
      MsgBox strComputer & ": " & objComputer.Manufacturer
      MsgBox strComputer & ": " & objComputer.Model
    Next
    
    Set colSMBIOS = objWMIService.ExecQuery ("Select * from Win32_SystemEnclosure") 
    For Each objSMBIOS in colSMBIOS
    MsgBox strComputer & ": " & objSMBIOS.SerialNumber
    Next

    Tinha a lista de todos os hostnames mais fica difícil digitar um a um...

    Estou tentando criar um script para carregar a lista em excel e mostra os resultados uma única vez.

    Segue abaixo o que fiz ate o momento mais preciso de ajuda para fazer funcionar.


    On Error Resume Next 
    
    StrFile = "C:\Users\Elisson\Desktop\Pasta1.xlsx"
    Set objExcel = CreateObject("Excel.Application")
    Set objWorkbook = objExcel.Workbooks.Open _
        (strFile,1)
    intRow = 2
    Do Until objExcel.Cells(intRow,1).Value = ""
     If objExcel.Cells(intRow,1).Value = UCASE(strCompname) then
      strComputer = objExcel.Cells(intRow,2)
    
    Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2") 
    
    Set colSettings = objWMIService.ExecQuery("Select * from Win32_ComputerSystem")
    
    For Each objComputer in colSettings
      MsgBox strComputer & ": " & objComputer.Manufacturer
      MsgBox strComputer & ": " & objComputer.Model
    Next
    
    Set colSMBIOS = objWMIService.ExecQuery ("Select * from Win32_SystemEnclosure") 
    For Each objSMBIOS in colSMBIOS
    MsgBox strComputer & ": " & objSMBIOS.SerialNumber
    Next
    
       
             End If
        intRow = intRow + 1
    
    Loop
    Set ActiveWorkbook = objExcel.ActiveWorkbook 
    objExcel.Application.DisplayAlerts = False
    objExcel.ActiveWorkbook.SaveAs strFile
    objExcel.ActiveWorkbook.Close
    objExcel.Application.Quit



    • Editado NOV4T0 sexta-feira, 30 de maio de 2014 11:05
    sexta-feira, 30 de maio de 2014 02:04

Respostas

  • E com a informação sendo preenchida no próprio Excel?

    On Error Resume Next 
    
    StrFile = "C:\temp\Pasta1.xlsx"
    Set objExcel = CreateObject("Excel.Application")
    Set objWorkbook = objExcel.Workbooks.Open _
        (strFile,1)
    
    intRow = 2
    Do Until objExcel.Cells(intRow,1).Value = ""
    
    	'Preeche strComputer com o valor da primeir coluna
    	strComputer = objExcel.Cells(intRow,1).Value
    
    	Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
    	
    	Set colItems = objWMIService.ExecQuery("Select * from Win32_ComputerSystem",,48)
    	For Each objItem in colItems
    		objExcel.Cells(intRow,2).Value = objItem.Manufacturer
    		objExcel.Cells(intRow,3).Value = objItem.Model
    	Next
    
    	Set colSMBIOS = objWMIService.ExecQuery ("Select * from Win32_SystemEnclosure") 
    	For Each objSMBIOS in colSMBIOS
    		objExcel.Cells(intRow,4).Value = objSMBIOS.SerialNumber
    	Next
    
    	intRow = intRow + 1
    
    Loop
    Set ActiveWorkbook = objExcel.ActiveWorkbook 
    objExcel.Application.DisplayAlerts = False
    objExcel.ActiveWorkbook.SaveAs strFile
    objExcel.ActiveWorkbook.Close
    objExcel.Application.Quit


    Fábio de Paula Junior

    sexta-feira, 30 de maio de 2014 17:57
    Moderador

Todas as Respostas

  • E com a informação sendo preenchida no próprio Excel?

    On Error Resume Next 
    
    StrFile = "C:\temp\Pasta1.xlsx"
    Set objExcel = CreateObject("Excel.Application")
    Set objWorkbook = objExcel.Workbooks.Open _
        (strFile,1)
    
    intRow = 2
    Do Until objExcel.Cells(intRow,1).Value = ""
    
    	'Preeche strComputer com o valor da primeir coluna
    	strComputer = objExcel.Cells(intRow,1).Value
    
    	Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
    	
    	Set colItems = objWMIService.ExecQuery("Select * from Win32_ComputerSystem",,48)
    	For Each objItem in colItems
    		objExcel.Cells(intRow,2).Value = objItem.Manufacturer
    		objExcel.Cells(intRow,3).Value = objItem.Model
    	Next
    
    	Set colSMBIOS = objWMIService.ExecQuery ("Select * from Win32_SystemEnclosure") 
    	For Each objSMBIOS in colSMBIOS
    		objExcel.Cells(intRow,4).Value = objSMBIOS.SerialNumber
    	Next
    
    	intRow = intRow + 1
    
    Loop
    Set ActiveWorkbook = objExcel.ActiveWorkbook 
    objExcel.Application.DisplayAlerts = False
    objExcel.ActiveWorkbook.SaveAs strFile
    objExcel.ActiveWorkbook.Close
    objExcel.Application.Quit


    Fábio de Paula Junior

    sexta-feira, 30 de maio de 2014 17:57
    Moderador
  • Muito Obrigado Fábio!

    Funciono perfeitamente.

    Att

    segunda-feira, 2 de junho de 2014 12:44