|
Prompting for the computer name in an unattended installation of Windows Server 2008 |
|
|
I mentioned in a previous post that I’d been working with some customers on Windows Server 2008 automated installations of the traditional kind, i.e. using an answer file as opposed to the newer technologies such as WDS and MS Deployment. Well, a question came up that wasn’t as easy to answer as you might think. It was something like this “Can we get it [Windows Server 2008 unattended installation] to prompt for a computer name during installation as opposed to performing the rename as a post installation task?” If any of you have been playing with Vista unattended installations you’ll no doubt shout “sure, that’s easy” or “I was getting Vista to do that when I didn’t want it to”, however Server 2008 doesn’t prompt for a computer name during a full unattended installation at all. You’ll be prompted if you simply wish to automate the Out of Box Experience (OOBE) after SYSPREP has been run, but ignoring the ComputerName property in the autounattend.xml file will result in a random name, just like using the wildcard value in Vista.
The official stance, from Microsoft’s documentation, is that this is by design. The idea here is that the installation is as streamlined as possible, with basic tasks such as configuring the time zone, computer name and remote desktop, automatic updates, for example, being configured “post-installation”. Remember, each time an administrator logs on for the first time the Initial Configuration Tasks page is displayed (and subsequently until you tick the box telling Windows to stop bugging you with it). This is the configuration interface for these trivial tasks.
Based on this information I would normally recommend to customers that they follow this advice and perform these post-installation tasks via automation in any number of ways, e.g. systems management software, post-installation scripts or have Microsoft deployment or WDS do it. However, my customer was adamant that she didn’t want to use WDS or MS Deployment and that “post-installation” scripts were not suitable for her environment therefore, as the customer is always right, I started asking my deployment expert friends for a solution. Well, we’ve got a solution but I wouldn’t call it graceful... ;-)
Earlier I said that a SYSPREP answer file for configuring the OOBE would prompt, therefore the answer to getting the autounattend.xml file to prompt is to run SYSPREP as a FirstLogonCommand. The following two [synchronous] FirstLogonCommands will enable you to prompt for a computer name during an unattended installation without any need to change your answer file and without getting into a loop state whereby you SYSPREP every time you run your first logon command, thus resulting in a continuous OOBE.
[oobeSystem] | Microsoft-Windows-Shell-Setup | FirstLogonCommands SynchronousCommand[Order=”1”] c:\windows\system32\cmd.exe /c if not exist c:\ sysprep-copy-log.txt copy e:\autounattend.xml c:\sysprep-unattend.xml > c:\sysprep-copy-log.txt
SynchronousCommand[Order=”2”] c:\windows\system32\cmd.exe /c if not exist c:\sysprep-runyet-log.txt c:\windows\system32\sysprep\sysprep.exe /generalize /oobe /reboot /unattend:c:\sysprep-unattend.xml > c:\sysprep-runyet-log.txt
Adding these commands to the OOBE phase of your autounattend.xml will result in the very first pass copying the autounattend.xml to the local hard drive and then running SYSPREP and pointing to that answer file. The second time we run these commands they won’t run as the IF NOT command will return FALSE because we output text files the first time the commands ran.
If the autounattend.xml answer file runs a synchronous task to configure server roles (via SERVERMANAGERCMD.EXE) like I showed in my previous post that command needs to be shunted to Order=”3” and also requires an IF NOT evaluation in front of it, like so:
c:\windows\system32\cmd.exe /c if not exist c:\sysprep-runyet-log.txt
Note. Synchronous command is one single line with no breaks. I've added line breaks for readability and formatting purposes only. |