«

»

Apr 20 2014

HOWTO: Automate Deployment of VMware Workstation VMs

This HOWTO describes the fastest way I’ve figured out thus far to deploy net-new Windows 2012 VMs using VMware Workstation for a Lab environment.  The first thing we need to do is build our "golden master" VM.  For our purposes, we will be using the Windows 2012 R2 180 Trial ISO which is freely available to download from Microsoft.  (Note, this script assumes you have already created a domain controller.  If you have not, then the domain joining functionality of this script will fail obviously.  I’ll likely create a new post on how to automate the deployment of that too at some point.)

  • Once you have the ISO, build a new VM and install Windows 2012 on the VM as you normally would
  • Run all windows updates on the VM to make it as current as possible
  • Make any other configuration changes you’d like.  My changes included:
    • Install Dot Net since many things will require it anyway
    • Set Keyboard refresh rate
    • Allow ICMP through the firewall
    • Disable IE Security Configuration
    • Enable Hidden files and file extensions
    • Add Notepad2 to the right click context menu
    • Copy my standalone tools folder to c:\bin
    • And more…

  • Once you’re satisfied with the VM, copy and paste the following XML into c:\windows\system32\sysprep\Autounattend.xml

  • These settings will take care of the following for you:
    • Skip the language and region settings screens that normally occur after a sysprep
    • Skips the EULA screen that normally appears
    • Sets the default local administrator password (must be changed above)
    • Sets the default time zone
    • Copies over the existing profile settings so that UI changes made prior to the sysprep are carried over
  • Next, create a file called C:\users\administrator\desktop\computersetup.ps1 and place the following inside it

  • Lastly, run the following command to sysprep the VM:

c:\windows\system32\sysprep\sysprep /generalize /oobe /shutdown /unattend:Autounattend.xml

  • With the VM powered off, right click on it and choose Manage / Clone and create a Linked Clone
  • Power up the clone.  If all goes according to plan, with out you doing anything, the system should automatically boot to the login screen.  Login with the local admin password and double click on the computersetup script on the desktop
  • Provide the desired computer name, IP address and press "y" to join the computer to the domain

Congratulations, after this final reboot, the server should now be ready for you to use with all the latest updates installed, all of your custom software, tools and other configurations already present!

It’s also worth noting that the 180 day trial countdown that appears in the bottom right corner of the screen appears to reset on each clone and therefore this template should in theory last indefinitely.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">