We help IT Professionals succeed at work.

Name computer with serial # and join to domain?

825 Views
Last Modified: 2012-05-11
Does anyone have a working script or know of a way to script VBScript or Batch file that will do the following:

1. Name the computer with three parts to the name separated by a hyphen (- sign): three letter city code - the letters "LP" - then the service tag (it's a Dell). So the example computername would be HOU-LP-ServiceTag (where ServiceTag is the the 7 character serial like most Dells have.
2. Then join the system to the domain, AND POSSIBLY put it into the OU automatically (OU=Laptop,OU=Houston,OU=Initech Workstations,DC=Initech,DC=com).


I have this script below which is a script that successfully gets the service tag/serial number, but it merely inputs it into the clipboard (so you can go paste it somewhere).
I am not the author behind the script, do not have the expertise to manipulate it with the automation parts.
strComputer = InputBox("Enter a computer name to get service tag")
 
If IsEmpty(strComputer) Then
    MsgBox "Cancelled", vbExclamation, "Cancel Pressed"
ElseIf Len(strComputer) = 0 Then
    MsgBox "You did not enter a PC name.", vbInformation, "OK pressed"
Else
    Set objWMIService = GetObject("winmgmts:" & _
            "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2") 
 
    For Each objSMBIOS In objWMIService.ExecQuery("Select * from Win32_SystemEnclosure") 
        strSerialNumber = objSMBIOS.SerialNumber
 
        Set objIE = CreateObject("InternetExplorer.Application")
        objIE.Navigate("about:blank")
        objIE.document.parentwindow.clipboardData.SetData "text", strSerialNumber
        objIE.Quit
        
        Wscript.Echo "The service tag for " & strComputer & " is: " & strSerialNumber
    Next
End If

Open in new window

Comment
Watch Question

CERTIFIED EXPERT
Commented:
Unlock this solution and get a sample of our free trial.
(No credit card required)
UNLOCK SOLUTION
Commented:
Unlock this solution and get a sample of our free trial.
(No credit card required)
UNLOCK SOLUTION

Author

Commented:
Ok great, thx
Unlock the solution to this question.
Thanks for using Experts Exchange.

Please provide your email to receive a sample view!

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.