Jump to content
  • entries
    2
  • comments
    8
  • views
    197

Sysprepping existing machines and auto-domain joining


This is prompted by this post asking how you can script many machines to get a new SID and keep their existing name.

 

In my replies in the post I suggested that it should be possible to script sysprep and I've now put together a script which I think will do this. I've done some testing but if you're going to use this for real then it really needs testing a bit more thoroughly!

 

To make this work you need some way of running a script on the machine; if the machines were joined to a Windows domain then you could just use a machine startup script. I'm assuming something similar is available in Netware; if not, then psexec could be used to run the script remotely but it's hard then to make sure it doesn't run while the machine is in use (you don't want that, because the machine is going to reboot)

 

The script attached assumes you've got a server called server01 with a share called files; in this share is a folder called sysprep which contains the standard sysprep files (download from the Microsoft website; make sure you have the version for XP SP3). You need to replace the sysprep.inf file with the one attached here.

 

Now you need to edit the script file to match your setup - the first few lines specify the name of the server and the share as well as a username and password with access to that shared folder.

 

The sysprep.inf file also needs editing; it should be obvious what you're changing (first password is local admin password that you want on the new machine; even if you don't want to change it, you have to set it here otherwise the process will stop with a prompt for password).

 

Enter your own volume license key (pretty sure the one shown won't work :-)) and the names you want showing as FullName and OrgName. Leave alone the line saying "Computername=DummyName" because this will be replaced by the script with the name of the computer.

 

Finally, if you want to join a Windows domain at the same time, complete the details under [identification]; the username and password need to have rights to join computers to the domain but don't need to be domain admin. If you don't want the computers ending up in the Computers container then include an OU and the account will be created there. The obvious next step for this is to create a database of existing computers and the OU you want them in; the script would then put the correct OU in the Identification section. This, as they say, is let as an exercise for the reader :-)

 

If you just want the computers leaving in a workgroup then remove everything under [identification] and replace with JoinWorkgroup=WorkgroupName

 

[GuiUnattended]
   AdminPassword="Really_Secret_Password"
   OEMDuplicatorstring=AnythingYouNeedToIdentifyThis

[userData]
   ProductKey=12345-12345-12345-12345-12345
   FullName="Maths Department"
   OrgName="Imperial College"
   ComputerName=DummyName

[identification]
   JoinDomain=Imperial.local
   DomainAdmin=imperial\administrator
   DomainAdminPassword=ThePasswordForThisAccount
   MachineObjectOU="OU=NewComputers,dc=imperial,dc=local"

 

The actual script is fairly simple. It starts by using WMI to get the current computer name and the windows folder (we're going to put a flag file in there)

It then tries to check if the script has been run previously; we don't want to keep setting up a new SID everytime it starts. It does this by looking for the flag file.

If the file is found then it reads it - there should be a SID in it. This is then compared to the current SID. If they're different then the script must have been run (or something else has changed SID which is what we want) so the script quits.

 

A drive is mapped to the server and all the sysprep files copied to the local machine. sysprep.inf is updated to include the name we want for this computer and then the current

machine SID is written to the flag file. Finally, sysprep is run so that it will force a reboot and a mini-setup which handles the SID change and domain join etc.

 

The GetSID function basically uses WMI to find the SID of the local administrator (only account you can guarantee to be present!) - everything before the "-500" is the bit which identifies the machine and will change when the machine SID changes.

0 Comments


Recommended Comments

There are no comments to display.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...