Link to home
Start Free TrialLog in
Avatar of Garry Shape
Garry ShapeFlag for United States of America

asked on

Name computer with serial # and join to domain?

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

ASKER CERTIFIED SOLUTION
Avatar of Tony Massa
Tony Massa
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Garry Shape

ASKER

Ok great, thx