packer-windows icon indicating copy to clipboard operation
packer-windows copied to clipboard

Add Option To Sysprep As Shutdown Command

Open joefitzgerald opened this issue 11 years ago • 6 comments

This would ensure that a base box does not begin counting down the activation clock until you use it for the first time - at the expense of using up one of the three sysprep /generalize runs that you can do (http://technet.microsoft.com/en-us/library/dd744512(v=ws.10).aspx).

joefitzgerald avatar Jan 16 '14 21:01 joefitzgerald

Could this sysprep be used to prepare the basebox in a way to rename the computername after the next boot which is then done by first vagrant up call?

I think of a way

  1. packer shuts Down the basebox with sysprep
  2. Add basebox to vagrant
  3. vagrant up with hostname setting in Vagrantfile
  4. vagrant and propably the vagrant-windows plugin sets the hostname and the new created box has the computername without the need of another reboot?

I don't know sysprep enough, but I have seen manually created VMs which ask for a new computername on first boot. If this could be set with something like an unattend.xml on boot time by vagrant then this could save me one reboot.

At the moment I have to reboot freshly created vagrant Windows boxes so they really have their new computernames from vagrant-windows plugin.

StefanScherer avatar Apr 11 '14 17:04 StefanScherer

My Packer shutdown command specifies another unattend xml file - which contains the new computer name. This is run on first boot after Packer has finished with the box.

"shutdown_command": "c:/windows/system32/sysprep/sysprep.exe /generalize /oobe /quiet /shutdown /unattend:a:/unattend.xml",

sneal avatar Apr 11 '14 19:04 sneal

Can you please post your unattend.xml I do not seem to be able to change the computername as it errors out.

ghost avatar Jul 22 '14 22:07 ghost

+1 to this idea, I'll look into it, but like others I don't have much experience with sysprep. @sneal could you post your unattend.xml file for this? Any thoughts on how to pass the hostname to sysprep through an environment variable or something along those lines?

kensykora avatar Aug 16 '14 01:08 kensykora

I've been using this one for 2008R2: https://gist.github.com/stonith/33a75407b465cfbf4f5e

Specify the ComputerName on line 39. I'm also uninstalling OpenSSH on first boot but that can be removed.

stonith avatar Aug 17 '14 07:08 stonith

Anyone still working on this ?

lilo6723 avatar Apr 05 '17 12:04 lilo6723