Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Clear Service Tag

Status
Not open for further replies.

sotghalz

Technical User
Apr 11, 2007
57
US
This script works great except it keeps the service tag for the next line from the previous workstation. How do I clear the vaule?

Code:
On Error Resume Next

Const ForAppending = 8

Set oFSO = CreateObject("Scripting.FileSystemObject")
set WSHShell = wscript.createObject("wscript.shell")
Set oTextStream = oFSO.OpenTextFile("\\Path\wslist.txt")
RemotePC = Split(oTextStream.ReadAll, vbNewLine)
oTextStream.Close

Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.CreateTextFile("\\path\ScriptLog.txt", ForAppending, True)

For Each strComputer In RemotePC

  Set objWMIService = GetObject("winmgmts:" _
      & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
      
  Set colBIOS = objWMIService.ExecQuery("Select * from Win32_BIOS")

    For each objBIOS in colBIOS
      objFile.WriteLine strComputer & "," & objBIOS.Manufacturer & "," & objBIOS.SerialNumber
    Next
Next
objFile.Close
 
Set the variable value to null or 0 at the beginning of the loop.

----------------------------
Josh

 
Code:
...
For Each strComputer In RemotePC
  Set objWMIService = GetObject("winmgmts:" _
      & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
  If Err.Number = 0 Then
    Set colBIOS = objWMIService.ExecQuery("Select * from Win32_BIOS")
    If Err.Number = 0 Then
      For each objBIOS in colBIOS
        objFile.WriteLine strComputer & "," & objBIOS.Manufacturer & "," & objBIOS.SerialNumber
      Next
    Else
      objFile.WriteLine strComputer & ", Error Win32_BIOS"
    End If
  Else
    objFile.WriteLine strComputer & ", Error WMI"
  End If
  Err.Clear
Next
...

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
intelwizrd and PHV,

Thanks for your help. This helped out a lot. In turn it just showed me how many errors I really have. Is there a way to add the SMBIOS variables on the same line?

objSMBIOS.PartNumber
objSMBIOS.SerialNumber
objSMBIOS.SMBIOSAssetTag

or...

The majority of my errors are (Error WMI), does this mean I have a different issue?
 
I just changed it all to Win32_SystemEnclosure and still got a "Error WMI"

Code:
Set colSMBIOS = objWMIService.ExecQuery("Select * from Win32_SystemEnclosure")

Currently troubleshooting...
 
Try this:
objFile.WriteLine strComputer & ", Error WMI " & Err.Number & " " & Err.Description & " " & Err.Source

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Thanks for the debug code:

Results:
-462
-The remote server machine does not exist or is unavailable
-Microsoft VBScript runtime error
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top