I have been working with the public beta of Windows Server 2008 R2 and have been exploring quite a few features of this new release. Of Course, native VHD boot is one of them. On my home PC, I have R2 Enterprise edition with AIK tools to capture OS in to VHDs whenever I need. However, I find this process of manually capturing VHDs a bit time consuming and repetitive task. So, decided to automate it so that I can do something else while the VHD creation is in progress. Here is the script if you are as lazy as me 🙂
What this script does is simple. You need to unzip the downloaded zip file to some location on your computer and at the command prompt, just run cscript captureVHD.vbs /src:<DVD Drive Letter>. For example, on my system, C:\> cscript c:\scripts\captureVHD.vbs /src:D:
This, depending on the OS DVD (Windows 7 or Server 2008 R2 only) you have, will display a menu as shown here.
All you need to do is enter the number against one of the images listed there or just enter A or a to capture all images as VHDs. This takes a few minutes to complete and copies all VHDs to %systemdrive%
Some known issues
1. Windows AIK path is hard coded in the script. You may have to change it if you did not install Windows AIK at the default path or your %systemdrive% is not C:
2. Size and type of the VHD will be 40GB and Dynamic respectively. This is, currently, not a configurable option. You can change the script to suit your needs.
3. This script always copies the VHDs to %systemdrive%
4. VHDs captured using this method cannot be conected to a Hyper-V VM directly. You will have to follow a few steps mentioned in this post
Here is the link to script download http://188.8.131.52/blog/wp-content/uploads/2009/01/capturevhd.zip