Jump to content

TBOMB

Members
  • Posts

    17
  • Joined

  • Last visited

Everything posted by TBOMB

  1. Not a permissions issue. If I take a computer that has a fresh (just meaning never been on a domain) install of windows and whatever apps I want, run this little program of ours it does exactly what we want it to do. Renames it, reboots, joins AD in the correct OU, reboots and waits for a login. If that point I go to system properties, move it from the domain and to a workgroup, reboot. Go into AD users and computers and remove the (now disabled) computer account and then try to run our app again, it gives some generic error about something not being an object. (Sorry so vague, I'll snap a screen shot of the error tomorrow and post it for you). Now if I take that same computer and put in another drive with a clean system on it (same thing, I just mean that it's never been on a domain before) and run the app it works fine. So it's not an AD thing, it's not a permissions issue, it's not really the app per/say. It would seem to me that something in the app looks at something on the PC using WMI or registry, and is choking because if that system was ever joined to the domain, it leaves a trail somewhere that is confusing the app. Even though all the proper steps have been taken to remove the computer from the domain both locally and in AD, it still has some trace of information somewhere that the app looks at that says it was (or is) on the domain. As a side note. How hard would it be to add something that would change the first login to choose the domain as the place to login rather than the local system? Let me clerify. When windows boots up and you hit Ctl+Alt+del to login, there are three text boxes, Username, password, and login to, the default location to log into is the last place it logged into before. And since the last place these systems logged in was locally, they have the computer name selected in the "Log into:" text box. My users aren't bright enough to drop down the list and choose the domain name and will sit there for an hour trying to log into the local machine with their network login despite my instructions letting them know that after we re-image their computer they need to change that the first time they log in. So what I need is something that after it joins the domain, but before it reboots, it goes into the registry and tells it that the "Log into:" box should have the domain selected not the local computer. That way I can just ghost their computer with our image that has this little app of ours set to run and not have to worry about getting a phone call from the user saying that they can't log in.
  2. Okay, after stripping out all the gui stuff, correcting a few more issues, and fine tunning it a little I've managed to get it to do what we need it to. The only weekness that I can see is that if you try to run it on a system that has EVER been on a domain before, you get errors and it fails. Must be some residual settings in either WMI or the registry. For example, if I take a system and remove it from the domain (the typical way through system properties) and reboot as it asks, then go to AD and remove the computer account, then try and run the app it spits out a bunch of errors. However, if I take the same machine and remove it from the domain, delete the computer account out of AD, format the drive, reload windows, then run the app it works. So this is the way I have it set up: I set up a system the way we need it with all the drivers for the different model Dell systems we have, all the software we use etc. Then I copy the app to a hidden directory, setup sysprep to do a completely automatic setup with no interaction what-so-ever and detecting all hardware (both plu-n-pray and none) and then tell sysprep to login as local admin 2 times and run this app at first login. Then I run sysprep and when it shuts down I create a ghost image of it and either put it on a DVD with the ghost boot/auto-clone settings or put the image on our ghost cast server. Then when I need to setup a new system or re-image an old one, I simply clone it using this image and walk away! It works great. It clones the system, changes the name to D+servicetag, reboots, joins the domain in the correct OU, reboots and when the user comes in the next morning it sitting at the login just waiting for them and I didn't have to do a thing!
  3. sorry for the double post. too much caffiene, clicked the "add reply" button twice. Anyway, moved past that issue and now I'm to another error. Please see the bmp I uploaded. Think this one is on line 53. error05.bmp
  4. It looks like one (or both) of these two variable on line 36 isn't being set anywhere. $strComputer $strComputerDomain should they be set somewhere or just renamed to one of the variables we declared at the top? We're half way there! It already changed the computer name, rebooted, and then ran itself again! SOOO sweet.
  5. It looks like one (or both) of these two variable on line 36 isn't being set anywhere. $strComputer $strComputerDomain should they be set somewhere or just renamed to one of the variables we declared at the top? We're half way there! It already changed the computer name, rebooted, and then ran itself again! SOOO sweet.
  6. Actually, maybe I gave up too soon! I just commented out the line you suggested and ran it and sure enough, it changed the name as I need it and rebooted, ran the script again... and then gave another error. But hey, it's almost there! I noticed on the next part (joining AD) it looks like it makes a bunch of message boxes. I don't mind if it just pops up and gives the status, but I really need this to be automatic and not require any user input at all and just do it's thing. Anyway, here is the current error:
  7. My problem is automating this whole thing. I have 350 systems I need to clone over the next month and currently my methods are not very productive. Right now I can only do about 5 a night because I have to come in early in the morning and manually go to each of the ghosted systems and change the name to the "D"+ServiceTag (which is written on a label on the front of the computer as well), reboot, join the domain, reboot and move to the next. What I need to do is take advantage of Ghost's abilities to run a local or remote application after the cloning process that will do the same thing automatically without human intervention. If the best I can do is a program that pops up windows that need to be clicked on throughout the process, then I have no use for it as it won't save me any time. I had assumed that since your prepsys app did most of these things already, that it would be a simple enough procedure to create one that I could just hard code into it the necessary credentials and so on and let it just do it's thing but I guess it's not as easy as that. Like it ever is right? I really appreciate all your help anyway though but I guess I'm just destined to do this the hard way. I should just be glad that I have ghost and a Sonix and don't have to install everything by hand.
  8. Well, it's getting farther. Now I get the following: AutoIT Error Line 0 (File "C:\DED\newcode.exe"): GUICtrlSetData($current_action, "Changing Computer Name") GUICtrlSetData(^ERROR Error:Variable used without being declared.
  9. Okay, something's not happy. As soon as I run the exe made from the code it just opens a small window with an ok button. As I said earlier, the only things I changed are at the top where it says "Fill in this section" and even then I didn't do anything with the "$logondomain = @ComputerName" Here is the code I used exactly (changed the user name and passwords of course). CODE;Fill in this section ;----------------------------------- $script = "c:\DED\newcode.exe" ;Script location - needed for script to be put back in startup (to change the computer name) $logonusername = "Administrator" ;logon credentials for reboot $logonpassword = "ourpassword" $logondomain = @ComputerName $domjoinuser = "mydom\admin" ;user with permissions to join domain $domjoinpass = "adminpassword" $domjoindomain = "mydom" $domtojoin = "arsi" $OU = "ou=Group Policy Test Site,ou=employees,dc=mydom,dc=com" ;----------------------------------- $strComputer = "localhost" $wbemFlagReturnImmediately = 0x10 $wbemFlagForwardOnly = 0x20 $colItems = "" $objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\root\CIMV2") $colItems = $objWMIService.ExecQuery("SELECT * FROM Win32_SystemEnclosure", "WQL", $wbemFlagReturnImmediately + $wbemFlagForwardOnly) If IsObj($colItems) then For $objItem In $colItems $newname = "D" & $objItem.SerialNumber Next Else Msgbox(0,"WMI Output","No WMI Objects Found for class: " & "Win32_SystemEnclosure" ) Exit Endif If @ComputerName <> $newname Then MsgBox(0, "", "") Exit ;_ChangeComputerName($newname, $logonusername, $logonpassword, $logondomain, $script) Else _JoinToDomain($domjoindomain, $domjoinuser, $domjoinpass, $strComputer, $strComputerDomain, $strOU) EndIf Exit ;<--- Functions from Prepsys v0.94 - By Andrew Calcutt ---> Func _ChangeComputerName($newcomputername, $logonuser = "", $logonpass = "", $domain = "", $startprogram = "") GUICtrlSetData($current_action, "Changing Computer Name") RegWrite("HKLM\SYSTEM\CurrentControlSet\Control\ComputerName\ActiveComputerName", "ComputerName", "REG_SZ", $newcomputername) RegWrite("HKLM\SYSTEM\CurrentControlSet\Control\ComputerName\ComputerName\", "ComputerName", "REG_SZ", $newcomputername) RegWrite("HKLM\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters", "ComputerName", "REG_SZ", $newcomputername) RegWrite("HKLM\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters", "NV Hostname", "REG_SZ", $newcomputername) _Shutdown("REBOOT", "ADD", $logonuser, $logonpass, $domain, $startprogram) EndFunc ;==>_ChangeComputerName Func _JoinToDomain($strUserDomain, $strUser, $strPassword, $strComputer, $strComputerDomain, $strOU);joins compuer to domain ;GUI GUICtrlSetData($current_action, "Joining to Domain") GUICreate("Joining Computer To Domain", 392, 323, -1, -1, BitOR($WS_OVERLAPPEDWINDOW, $WS_CLIPSIBLINGS)) GUICtrlCreateLabel("Machine Name:", 10, 10, 80, 20) $machine_nameJD = GUICtrlCreateInput($strComputer, 100, 10, 280, 20) GUICtrlCreateLabel("Join Domain:", 10, 40, 90, 20) $jointodomain = GUICtrlCreateInput($strComputerDomain, 100, 40, 280, 20) GUICtrlCreateLabel("OU:", 10, 70, 90, 20) $JoinToOU = GUICtrlCreateInput($strOU, 100, 70, 280, 20) GUICtrlCreateLabel("Username:", 10, 100, 90, 20) $usernameJD = GUICtrlCreateInput($strUser, 100, 100, 280, 20) GUICtrlCreateLabel("Password:", 10, 130, 90, 20) $passwordJD = GUICtrlCreateInput($strPassword, 100, 130, 280, 20, $ES_PASSWORD) GUICtrlCreateLabel("Domain", 10, 170, 80, 20) $domainJD = GUICtrlCreateInput($strUserDomain, 100, 170, 280, 20) $join_edit = GUICtrlCreateEdit("", 10, 230, 370, 170) GUISetState() ;Join Domain Script Const $JOIN_DOMAIN = 1 Const $ACCT_CREATE = 2 Const $ACCT_DELETE = 4 Const $WIN9X_UPGRADE = 16 Const $DOMAIN_JOIN_IF_JOINED = 32 Const $JOIN_UNSECURE = 64 Const $MACHINE_PASSWORD_PASSED = 128 Const $DEFERRED_SPN_SET = 256 Const $INSTALL_INVOCATION = 262144 Dim $strDomainUser Dim $strFailString Dim $strSucceedString GUICtrlSetData($join_edit, "Joining Domain") $strDomainUser = $strUserDomain & "\" & $strUser $objNetwork = ObjCreate("WScript.Network") $objComputer = ObjGet("winmgmts:{impersonationLevel=Impersonate}!\\" & _ $strComputer & "\root\cimv2:Win32_ComputerSystem.Name='" & _ $strComputer & "'") $ReturnValue = $objComputer.JoinDomainOrWorkGroup ($strComputerDomain, _ $strPassword, _ $strDomainUser, _ $strOU, _ $JOIN_DOMAIN + $ACCT_CREATE) If ($ReturnValue <> 0) Then ;get the net helpmsg from the error code returned Dim $strHelpMsg, $command $command = "net helpmsg " & $ReturnValue $objShell = ObjCreate("WScript.Shell") $objScriptExec = $objShell.Exec ($command) ; store the error message into strHelpMsg $strHelpMsg = $objScriptExec.StdOut.ReadAll () $strFailString = "Join Failed" & @CRLF & _ "Computer: " & $strComputer & @CRLF & _ "Domain: " & $strComputerDomain & @CRLF & _ "User Name: " & $strDomainUser & @CRLF & _ "Error Message: " & $strHelpMsg GUICtrlSetData($join_edit, $strFailString) $join_button = GUICtrlCreateButton("Join Domain", 10, 200, 110, 20) $skip_button = GUICtrlCreateButton("Skip Joining Domain", 130, 200, 110, 20) GUISetState() While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE Or $msg = $skip_button GUIDelete("Joining Computer To Domain") ExitLoop Case $msg = $join_button $domainJD = GUICtrlRead($domainJD) $usernameJD = GUICtrlRead($usernameJD) $passwordJD = GUICtrlRead($passwordJD) $machine_nameJD = GUICtrlRead($machine_nameJD) $jointodomain = GUICtrlRead($jointodomain) $JoinToOU = GUICtrlRead($JoinToOU) GUIDelete("Joining Computer To Domain") _JoinToDomain($domainJD, $usernameJD, $passwordJD, $machine_nameJD, $jointodomain, $JoinToOU) ExitLoop Case Else ;;; EndSelect WEnd Return 0 Else $strSucceedString = "Join Succeeded" & @CRLF & _ "Computer: " & $strComputer & @CRLF & _ "Domain: " & $strComputerDomain & @CRLF & _ "User Name: " & $strDomainUser ;_RecordData($strComputer, $strUser, $strUserDomain, $strOU) GUICtrlSetData($join_edit, $strSucceedString) Sleep(5000) GUIDelete("Joining Computer To Domain") Return 1 EndIf EndFunc ;==>_JoinToDomain ;<--- End Functions from Prepsys v0.94 - By Andrew Calcutt --->
  10. "everything else seems right to me." So I don't need to change the line that says $logondomain = @ComputerName? (the "@Computername" also shows up in pink elsewhere in the script) "just remember for the script you will need those other 2 functions also. the _Shutdown and _Logon in addition to what i wrote origionally (as the _CHANGECOMPUTERNAME function uses _SHUTDOWN and _SHUTDOWN use _LOGON)" What tother two functions are you refering to. DId I miss something else? There wasn't anything else further down in the script that needed to be changed was there?
  11. couple of questions about this script. Again, definately NOT new to scripting, but definately AM new to autoit. i just want to make sure I am filling this out correctly. Please take a look, this is what I have changed and NOTHING else. I want to make sure that I am changing what I should and not changing what I shouldn't. $script = @C:\newcode.au3 ;assuming this is the path to this script $logonusername = "Adminuser" ;not real DUH $logonpassword = "adminpassword" ;also not real $logondomain = @ComputerName ;DID NOT CHANGE, that's what i need this script for $domjoinuser = "mydom\adminuser" ;not real $domjoinpass = "adminpassword" ;not real $domjoindomain = "mydom" $domtojoin = "Domain.local" ;DID NOT CHANGE $OU = "Group Policy Test Site" ;this is an OU that is a sub, sub, sub, OU to our domain Is that okay? Is there anything else that I need to change? Is there something that I changed and shouldn't have or changed incorrectly? Also, is it possible to turn this into an executable so that it will run on my computers without installing autoit or whatever?
  12. Thanks to the both of you! I will give it a try but it sure looks good to me.
  13. Thanks, I'll start toying with it and see if I can't make it work.
  14. Sorry, cut off most of the code, here's what comes after: 'check for required paramaters If Not WScript.Arguments.Named.Exists("computer") Or Not WScript.Arguments.Named.Exists("name") Then WScript.Arguments.ShowUsage WScript.Quit End If 'was ping requested? If WScript.Arguments.Named.Exists("ping") Then If bPingAvailable Then Verbose "will attempt to ping all connections to improve performance" Else WScript.Echo "*** /ping not supported prior to Windows XP" End If End if 'either /list, /computer, or /container was specified: Dim sName If WScript.Arguments.Named("list") <> "" Then 'specified list - read names from file Dim oFSO, oTS Verbose "Reading names from file " & WScript.Arguments.Named("list") Set oFSO = WScript.CreateObject("Scripting.FileSystemObject") On Error Resume Next Set oTS = oFSO.OpenTextFile(WScript.Arguments.Named("list")) If Err <> 0 Then WScript.Echo "Error opening " & WScript.Arguments.Named("list") WScript.Echo Err.Description WScript.Quit End If Do Until oTS.AtEndOfStream sName = oTS.ReadLine TakeAction sName Loop oTS.Close Elseif WScript.Arguments.Named("container") <> "" Then 'specified container - read names from AD Dim oObject, oRoot, oChild Verbose "Reading names from AD container " & WScript.Arguments.Named("container") On Error Resume Next Set oRoot = GetObject("LDAP://rootDSE") If Err <> 0 Then WScript.Echo "Error connecting to default Active Directory domain" WScript.Echo Err.Description WScript.Quit End If Set oObject = GetObject("LDAP://ou=" & WScript.Arguments.Named("container") & _ "," & oRoot.Get("defaultNamingContext")) If Err <> 0 Then WScript.Echo "Error opening organizational unit " & WScript.Arguments.Named("container") WScript.Echo Err.Description WScript.Quit End If WorkWithOU oObject Elseif WScript.Arguments.Named("computer") <> "" Then 'specified single computer Verbose "Running command against " & WScript.Arguments.Named("computer") TakeAction WScript.Arguments.Named("computer") End If 'display output so user will know script finished WScript.Echo "Command completed." ' ---------------------------------------------------------------------- ' Sub WorkWithOU ' ' Iterates child objects in OU; calls itself to handle sub-OUs If ' /recurse argument supplied ' ---------------------------------------------------------------------- Sub WorkWithOU(oObject) For Each oChild In oObject Select Case oChild.Class Case "computer" TakeAction Right(oChild.Name,len(oChild.name)-3) Case "user" Case "organizationalUnit" If WScript.Arguments.Named.Exists("recurse") Then 'recursing sub-OU Verbose "Working In " & oChild.Name WorkWithOU oChild End If End Select Next End Sub ' ---------------------------------------------------------------------- ' Sub TakeAction ' ' Makes connection and performs command-specific code ' ---------------------------------------------------------------------- Sub TakeAction(sName) 'verbose output? Verbose "Connecting to " & sName 'ping before connecting? If WScript.Arguments.Named.Exists("ping") Then If Not TestPing(sName,bPingAvailable) Then LogBadConnect(sName) Exit Sub End If End If '############################################# '# COMMAND CODE GOES HERE # '#-------------------------------------------# '# # Dim oWMIService, cComputers, oComputer, ErrResults On Error Resume Next Verbose " Attempting to connect to " & sName Set cComputers = QueryWMI(sName,"root\cimv2","Select * From Win32_ComputerSystem","","") If Not IsObject(cComputers) Then WScript.Echo " *** Error connecting to " & sName Else For Each oComputer In cComputers If WScript.Arguments.Named.Exists("ping") Then If TestPing(WScript.Arguments.Named("name"),bPingAvailable) Then WScript.Echo " *** " & WScript.Arguments.Named("name") & " already responds to ping" Exit sub End if End if Verbose " Renaming " & sName & " to " & WScript.Arguments.Named("name") ErrResults = oComputer.Rename(WScript.Arguments.Named("name"),Null,Null) If ErrResults <> 0 Then WScript.Echo " *** Error renaming: " & ErrResults Else Verbose "Rename successful. Restart of remote computer is necessary." End If Next End If '# # '#-------------------------------------------# '# END COMMAND CODE # '############################################# End Sub ' ---------------------------------------------------------------------- ' Sub LogBadConnect ' ' Logs failed connections to a log file. Will append if file already exists. ' ---------------------------------------------------------------------- Sub LogBadConnect(sName) If WScript.arguments.Named.Exists("log") Then Dim oLogFSO, oLogFile Set oLogFSO = WScript.CreateObject("Scripting.FileSystemObject") On Error Resume Next Set oLogFile = oLogFSO.OpenTextFile(WScript.Arguments.Named("log"),8,True) If Err <> 0 Then WScript.Echo " *** Error opening log file to log an unreachable computer" WScript.Echo " " & Err.Description Else oLogFile.WriteLine sName oLogFile.Close Verbose " Logging " & sName & " as unreachable" End If End If End Sub ' ---------------------------------------------------------------------- ' Function TestPing ' ' Tests connectivity to a given name or address; returns true or False ' ---------------------------------------------------------------------- Function TestPing(sName,bPingAvailable) If Not bPingAvailable Then WScript.Echo " Ping functionality not available prior to Windows XP" Exit Function End If Dim cPingResults, oPingResult Verbose " Pinging " & sName Set cPingResults = GetObject("winmgmts://./root/cimv2").ExecQuery("SELECT * FROM Win32_PingStatus WHERE Address = '" & sName & "'") For Each oPingResult In cPingResults If oPingResult.StatusCode = 0 Then TestPing = True Verbose " Success" Else TestPing = False Verbose " *** FAILED" End If Next End Function ' ---------------------------------------------------------------------- ' Sub Verbose ' ' Outputs status messages if /verbose argument supplied ' ---------------------------------------------------------------------- Sub Verbose(sMessage) If WScript.Arguments.Named.Exists("verbose") Then WScript.Echo sMessage End If End Sub ' ---------------------------------------------------------------------- ' Sub LogFile ' ' Outputs specified text to specified logfile. Set Overwrite=True To ' overwrite existing file, otherwise file will be appended to. ' Each call to this sub is a fresh look at the file, so don't Set ' Overwrite=True except at the beginning of your script. ' ---------------------------------------------------------------------- Sub LogFile(sFile,sText,bOverwrite) Dim oFSOOut,oTSOUt,iFlag If bOverwrite Then iFlag = 2 Else iFlag = 8 End If Set oFSOOut = WScript.CreateObject("Scripting.FileSystemObject") On Error Resume Next Set oTSOUt = oFSOOut.OpenTextFile(sFile,iFlag,True) If Err <> 0 Then WScript.Echo "*** Error logging to " & sFile WScript.Echo " " & Err.Description Else oTSOUt.WriteLine sText oTSOUt.Close End If End Sub ' ---------------------------------------------------------------------- ' Function QueryWMI ' ' Executes WMI query and returns results. User and Password may be ' passed as empty strings to use current credentials; pass just a blank ' username to prompt for the password ' ---------------------------------------------------------------------- Function QueryWMI(sName,sNamespace,sQuery,sUser,sPassword) Dim oWMILocator, oWMIService, cInstances On Error Resume Next 'create locator Set oWMILocator = CreateObject("WbemScripting.SWbemLocator") If sUser = "" Then 'no user - connect w/current credentials Set oWMIService = oWMILocator.ConnectServer(sName,sNamespace) If Err <> 0 Then WScript.Echo "*** Error connecting to WMI on " & sName WScript.Echo " " & Err.Description Set QueryWMI = Nothing Exit Function End If Else 'user specified If sUser <> "" And sPassword = "" Then 'no password - need to prompt for password If LCase(Right(WScript.FullName,11)) = "cscript.exe" Then 'cscript - attempt to use ScriptPW.Password object Dim oPassword Set oPassword = WScript.CreateObject("ScriptPW.Password") If Err <> 0 Then WScript.Echo " *** Cannot prompt for password prior to Windows XP" WScript.Echo " Either ScriptPW.Password object not present on system, Or" WScript.Echo " " & Err.Description WScript.Echo " Will try to proceed with blank password" Else WScript.Echo "Enter password for user '" & sUser & "' on '" & sName & "'." sPassword = oPassword.GetPassword() End If Else 'wscript - prompt with InputBox() sPassword = InputBox("Enter password for user '" & sUser & "' on '" & sName & "'." & vbcrlf & vbcrlf & _ "WARNING: Password will echo to the screen. Run command with CScript to avoid this.") End if End If 'try to connect using credentials provided Set oWMIService = oWMILocator.ConnectServer(sName,sNamespace,sUser,sPassword) If Err <> 0 Then WScript.Echo " *** Error connecting to WMI on " & sName WScript.Echo " " & Err.Description Set QueryWMI = Nothing Exit Function End If End If 'execute query If sQuery <> "" Then Set cInstances = oWMIService.ExecQuery(sQuery,,48) If Err <> 0 Then WScript.Echo "*** Error executing query " WScript.Echo " " & sQuery WScript.Echo " " & Err.Description Set QueryWMI = Nothing Exit Function Else Set QueryWMI = cInstances End If Else Set QueryWMI = oWMIService End If End Function ' ---------------------------------------------------------------------- ' Function QueryADSI ' ' Executes ADSI query. Expects variable sQuery to include a COMPLETE ' query beginning with the provider LDAP:// or WinNT://. The query String ' may include a placeholder for the computer name, such as "%computer%". ' Include the placeholder in variable sPlaceholder to have it replaced ' with the current computer name. E.g., ' sQuery = "WinNT://%computer%/Administrator,user" ' sPlaceholder = "%computer% ' Will query each computer targeted by the script and query their local ' Administrator user accounts. ' ---------------------------------------------------------------------- Function QueryADSI(sName,sQuery,sPlaceholder) Dim oObject sQuery = Replace(sQuery,sPlaceholder,sName) On Error Resume Next Verbose " Querying " & sQuery Set oObject = GetObject(sQuery) If Err <> 0 Then WScript.Echo " *** Error executing ADSI query" WScript.Echo " " & sQuery WScript.Echo " " & Err.Description Set QueryADSI = Nothing Else Set QueryADSI = oObject End If End Function ]]> </script> </job>
  15. Sure. It uses WMI and windows scripting to change the name and I know that there is a way to also get the Dell service tag using WMI as well, so I guess I need to have something that pulls the service tag, adds a "D" in front and plugs it in as a variable for the following script to use as the new name. Anyway, not my script, it was one included in a scripting book I bought. <?xml version="1.0" ?> <package> <job id="ChangeComputerName" prompt="no"> <?job error="false" debug="false" ?> <runtime> <description> Change the computer name of the specified computer. </description> <named helpstring="Run command against single specified computer" name="computer" required="true" type="string"/> <named helpstring="Display detailed messages" name="verbose" required="false" type="simple"/> <named helpstring="File to log names which can't be reached" name="log" required="false" type="string"/> <named helpstring="Reduce timeout wait by pinging before attempting" name="ping" required="false" type="simple"/> <named helpstring="New computer name" name="name" required="true" type="string"/> </runtime> <object id="fso" progid="Scripting.FileSystemObject"/> &lt;script id="MultiComputer" language="VBScript"> <![CDATA[ '---------------------------------------------------------- ' Rollback System Restore Point '---------------------------------------------------------- 'make sure we're running from CScript, not WScript If LCase(Right(WScript.FullName,11)) <> "cscript.exe" Then If MsgBox("This script is designed to work with CScript, but you are running it under WScript. " & _ "This script may produce a large number of dialog boxes when running under WScript, which you may " & _ "find to be inefficient. Do you want to continue anyway?",4+256+32,"Script host warning") = 7 Then WScript.Echo "Tip: Run ""Cscript //h:cscript"" from a command-line to make CScript the default scripting host." WScript.Quit End If End If 'if ping requested, make sure we're on XP or later Dim bPingAvailable, oLocalWMI, cWindows, oWindows bPingAvailable = False Set oLocalWMI = GetObject("winmgmts:\\.\root\cimv2") Set cWindows = oLocalWMI.ExecQuery("Select BuildNumber from Win32_OperatingSystem",,48) For Each oWindows In cWindows If oWindows.BuildNumber >= 2600 Then bPingAvailable = True End If Next
  16. Still very new at this and need a little help. What I need to do is automate the computer naming process on our newly ghosted systems. Our naming convention is a "D" (for Dell) and the service tag. Like "D51VCG31" and I know I saw a script using powershell on this forum that can pull the dell service tag. So it would be nice if I could use this script to read the service tag from the system at first boot, then change the computer name to D+servicetag. I have a script that allows me to change the name and reboot, but I need to specify the name first so unless there is a way to make the output from the first script enter into into the second, I would need to find a way to combine the two. The Ghost image I use is a universal one I made for all our GX models that is then syspreped but right now, I set ghost to re-image only a few of our systems everynight because I need to come in and rename, reboot, join AD, and reboot before the users can use them so I am limited as to how many I can do at one time. I think I have found a script to remove them from AD just before ghost runs so I don't get duplicate names, but I still need to find an automated way to rename (with our naming convention) and join ad. Any ideas? Can this already do that?
  17. New to all of this. But is there a way to take the output of your script and have it put into another batch file? What I need to do is automate the computer naming process on our newly ghosted systems. Our naming convention is a "D" (for Dell) and the service tag. Like "D51VCG31". So it would be nice if I could use this script to read the service tag from the system at first boot, then change the computer name to D+servicetag. I have a script that allows me to change the name and reboot, but I need to specify the name first so unless there is a way to make the output from the first script enter into into the second, I would need to find a way to combine the two. Any ideas?
×
×
  • Create New...