Announcement

Collapse
No announcement yet.

Get PC name from Dell Service Tag

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Get PC name from Dell Service Tag

    Hi,

    I am wondering if it is possible to do the following with a VBScript:

    To get the PC name from just the DELL Service Tag?

    Any help would be greatly appreciated.

    EDIT:
    Startup script is not an option am not allowed use it
    Last edited by GTTDi; 15th May 2013, 13:01.

  • #2
    Re: Get PC name from Dell Service Tag

    What is your goal exactly?

    You could write a script that tries to connect to every client computer in AD. Or use a startup script that will run on every client. If the tag number is a match then the script logs the name of that computer to somewhere.


    /Rems
    Last edited by Rems; 15th May 2013, 12:07.

    This posting is provided "AS IS" with no warranties, and confers no rights.

    __________________

    ** Remember to give credit where credit's due **
    and leave Reputation Points for meaningful posts

    Comment


    • #3
      Re: Get PC name from Dell Service Tag

      My goal is, i have some PCs that i only have a record of there Service Tag and need to find the PC name associated with the specific service tags.

      Comment


      • #4
        Re: Get PC name from Dell Service Tag

        Originally posted by GTTDi View Post
        My goal is, i have some PCs that i only have a record of there Service Tag and need to find the PC name associated with the specific service tags.

        EDIT:
        Startup script is not an option am not allowed use it
        OK, how cAn we run the script, by visiting every computer with a pen drive in your hand maybe? Or can you run a script remotely against a group of computers (what's the OS)?


        /Rems

        This posting is provided "AS IS" with no warranties, and confers no rights.

        __________________

        ** Remember to give credit where credit's due **
        and leave Reputation Points for meaningful posts

        Comment


        • #5
          Re: Get PC name from Dell Service Tag

          First, get a list of all machines in your domain and put them in a text file called pcs.txt, for example. One hostname per line.

          Take the following VBScript snippet and save it to a file called GetSerial.vbs (or whatever you like):

          Code:
          On Error Resume Next
          
          strComputer = WScript.Arguments(0)
          
          UserName = ""
          Password = ""
          
          Set SWBemlocator = CreateObject("WbemScripting.SWbemLocator")
          Set objWMIService = SWBemlocator.ConnectServer(strComputer,"root\CIMV2",UserName,Password)
          Set colItems = objWMIService.ExecQuery("Select * from Win32_BIOS",,48)
          
          If Err.Number = 0 And IsObject(colItems) Then
          	For Each objItem in colItems
          		WScript.Echo strComputer & vbTab & objItem.Manufacturer & vbTab & objItem.SerialNumber
          	Next
          Else
          	WScript.Echo strComputer & vbTab & "WMI Error" & vbTab & Err.Description
          End If
          Now run the script against every PC in the list to get the serial numbers back for identification. From a CMD prompt run:

          Code:
          for /f %a in (pcs.txt) do cscript /nologo GetSerial.vbs %a >>serials.log
          It will attempt a remote WMI connection to each PC and query the serial number. All results will be logged to the serials.log file. Make sure to run the script while logged in as a user with admin rights on all PCs. You can also hard code the credentials in the script (not recommended).
          Jay Adams, Noxigen LLC

          Comment


          • #6
            Re: Get PC name from Dell Service Tag

            Originally posted by noxigen View Post
            First, get a list of all machines in your domain and put them in a text file called pcs.txt, for example. One hostname per line.

            Take the following VBScript snippet and save it to a file called GetSerial.vbs (or whatever you like):

            Code:
            On Error Resume Next
            
            strComputer = WScript.Arguments(0)
            
            UserName = ""
            Password = ""
            
            Set SWBemlocator = CreateObject("WbemScripting.SWbemLocator")
            Set objWMIService = SWBemlocator.ConnectServer(strComputer,"root\CIMV2",UserName,Password)
            Set colItems = objWMIService.ExecQuery("Select * from Win32_BIOS",,48)
            
            If Err.Number = 0 And IsObject(colItems) Then
                For Each objItem in colItems
                    WScript.Echo strComputer & vbTab & objItem.Manufacturer & vbTab & objItem.SerialNumber
                Next
            Else
                WScript.Echo strComputer & vbTab & "WMI Error" & vbTab & Err.Description
            End If
            Now run the script against every PC in the list to get the serial numbers back for identification. From a CMD prompt run:

            Code:
            for /f %a in (pcs.txt) do cscript /nologo GetSerial.vbs %a >>serials.log
            It will attempt a remote WMI connection to each PC and query the serial number. All results will be logged to the serials.log file. Make sure to run the script while logged in as a user with admin rights on all PCs. You can also hard code the credentials in the script (not recommended).
            Instead of using batch, why not put all of that functionality into the VBS script?

            Comment


            • #7
              Re: Get PC name from Dell Service Tag

              Out of habit. I usually create scripts that target a single machine so that I can execute them against multiple machines in parallel or import them into System Frontier.
              Last edited by noxigen; 27th May 2013, 04:05. Reason: typo
              Jay Adams, Noxigen LLC

              Comment


              • #8
                Re: Get PC name from Dell Service Tag

                Originally posted by noxigen View Post
                Out of habit. I usually create scripts that target a single machine so that I can execute them against multiple machines in parallel or import them into System Frontier.
                You could still make this dynamic in that way.

                Code:
                On Error Resume Next
                
                ' Input File Example:
                ' 127.0.0.1
                ' 127.0.0.1, UserName, Password'
                
                Dim fileStream, fileSystemObj
                Const ForReading = 1
                Dim strArr
                
                localUserName = ""
                localPass = ""
                
                If WScript.Arguments.Length = 0 Then
                	Call GetInfo("127.0.0.1", localUserName, localPass, False)
                Else
                	filePath = WScript.Arguments(0)
                	Set fileSystemObj = CreateObject("Scripting.FileSystemObject")
                	If fileSystemObj.FileExists(filePath) Then
                		Set fileStream = fileSystemObj.OpenTextFile(filePath, ForReading, 0)
                		Do Until fileStream.AtEndOfStream
                			strLn = fileStream.ReadLine()
                			If Trim(strLn) <> "" Then
                				arg1 = ""
                				arg2 = ""
                				strArr = Split(strLn, ",")
                				If UBound(strArr) = 2 Then
                					arg1 = Trim(strArr(1))
                					arg2 = Trim(strArr(2))
                				End If
                				Call GetInfo(Trim(strArr(0)), user, pass, True)
                			End If
                		Loop
                	Else
                		MsgBox "File does not exist: " & filePath, 48, "Error"
                	End If
                End If
                
                Sub GetInfo(strComputer, userName, pass, abortOption)
                	Set SWBemlocator = CreateObject("WbemScripting.SWbemLocator")
                	Set objWMIService = SWBemlocator.ConnectServer(strComputer,"root\CIMV2",userName,pass)
                	Set colItems = objWMIService.ExecQuery("Select * from Win32_BIOS",,48)
                
                	If Err.Number = 0 And IsObject(colItems) Then
                		Style = 64
                		If abortOption Then Style = 67
                		For Each objItem in colItems
                			Result = MsgBox("Computer: " & strComputer & vbNewLine & _
                			"Manufacturer: " & objItem.Manufacturer & vbNewLine & _
                			"SerialNumber: " & objItem.SerialNumber, Style, "WMI Results")
                			If abortOption And Result = 7 Then WScript.Quit(0)
                		Next
                	Else
                		MsgBox "(" & strComputer & ") - " & _
                		Err.Description, 48, "WMI Error"
                	End If
                End Sub
                You can specify a file that contains a list of computer names and optional username and password delimited by a "," (comma). So for instance the file may look like this:
                Code:
                127.0.0.1
                127.0.0.1, UserName, Password
                Where the username and password are optional for each line. Otherwise just invoking the script without any arguments assumes "127.0.0.1".

                Note: You could edit the script to output all of the information at the end once all queries are completed, or add a messagebox that has 2 buttons, and check for whether the user wants to continue checking the next one, otherwise exit the script.

                edit: I edited the script with the most up to date version I have right now.

                VBscript isn't really my thing, I know VB.net and C#, but I mainly deal with C/C++.

                Cheers,
                Ace
                Last edited by AceInfinity; 27th May 2013, 05:39.

                Comment

                Working...
                X