Prepare a Virtual Environment for testing
One of the more important tools I use in my day to day work is Virtual PC. To be honest I’ve been looking at VMware Workstation for a while because Virtual PC 2007 doesn’t support 64-bit guest operating systems. But that’s another story. Right now I manage with what I’ve got.
Why a virtual environment?
This might be the first question. Well it saves time and money. I can test different products and deployments without using a full expensive test lab. The virtual systems can’t replicate every possible scenario but I’ve managed fine so far.
You can’t test disk encryption and that’s to bad but almost anything else is possible without making changes to your production environment.
How to setup the environment
First of all you should create a few master images so you will be able to copy in servers and clients when you need new ones. This is simply done by installing a copy of Windows Server 2008, Windows 7 or any other system you might need in the future. I personally keep master images of
- Windows Server 2008 32-bit
- Windows Server 2003 R2 32-bit
- Windows 7 32-bit
- Windows XP Pro 32-bit
So if you need all of them you need to start installing. Just install the basic OS, install all/any tools you like to use. Maybe you even want install the Office suite. Another tool collection I suggest you install is the Sysinternals Suite. After you have installed all the basic Operating systems we need to Sysprep them so they can be used again and again without any collisions on SID:s etc.
Using Sysprep
After you have everything installed you need to sysprep your installation and let the guest operating system shut down so you can copy the virtual hard disk (.vhd) file. Sysprep has been integrated in Windows Vista and newer, XP and 2003 has the files on the installation media in the folder <DRIVE>:\Support\Tools\Deploy.cab . In Vista and newer you can find sysprep in the folder C:\Windows\System32\sysprep.
For Windows Server 2008 and Vista you need to install the Virtual Machine Addons to get it running smoothly and you really want them to be left alone by sysprep. After all we are running sysprep to get our master images for Virtual PC.
So to keep your Virtual Machine Additions in the image you need to create a sysprep.xml file in the sysprep folder. If you want to you can place anything in the Sysprep file but this is needed to keep the Virtual Machine additions for the next boot.
<unattend xmlns="urn:schemas-microsoft-com:unattend" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State">
<settings pass="generalize">
<component name="Microsoft-Windows-PnpSysprep" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" processorArchitecture="x86">
<PersistAllDeviceInstalls>true</PersistAllDeviceInstalls>
</component>
</settings>
</unattend>
Once you have the file saved in the C:\Windows\System32\Sysprep directory just run from the command prompt.
sysprep /generalize /unattend:sysprep.xml
After the computer shuts down you can move the .vhd file to a storage directory and name it something like Ws2008-master.vhd.
Windows 7 has a greatly improved support to run as a virtual machine so I’ve never had to install any of the additions on a Windows 7 image.
The result
The next time you need to “install” a new virtual Server or client just copy the .vhd file to another location and rename it. Create a new virtual machine and point it to the newly copied .vhd file. Boot the server or client and you’re done. Easy, fast and great for testing.
Virtual PC wants to store everything in your home folder but I like to keep my virtual machines in the root of a drive. So I know where to find them.
D:\VMS to keep the vmc files
D:\VMS\VHD to keep the .vhd files in use, not the master images
D:\VMS\Master to keep the master .vhd files
D:\VMS\ISOS to store any ISO files I might need.
You should set it up the way you like it but for me that keeps it in order and I know where to look for my files.
If you have any questions feel free to comment and I’ll answer anything I can.

