For MCTs: Classroom Setup Tools for MS Learning Hyper-V machines

(Download link below!)

If you set up a MS Learning Classroom with Hyper-V and the images provided by MS at the MCT download page you need to deploy the VHD files (and the other VM files of course) to “C:ProgrammeMicrosoft Learning<…>”

The last days I set up a new Hyper-V server at my office:

  • 128GB SSD => system
  • 2TB HDD => machines
  • 32GB RAM

I want to store the MS Learning machines on “D:” (=> 2TB).

The MS Learning machines have differential VHDs that are based on a couple of “Base VHDs”. In all differential VHD files there are references to the location of the original file:

image

Furthermore there are to files for every machine that contain config and export/import informations. This files have absolute file location references too.

Because this MS Learning machines are not productive Hyper-V machines I decided to manipulate a neseccary files to be able to store the machines on another drive. Manipulating this files is not supported!!!

My package contains 4 PowerShell scripts:

1. “Unpack”

image

This script allows you to decompress all compressed MS Learning machines in a folder to a destination folder.

To run the script you need to have “unrar.exe” in the same directory as the script. Download and execute this file ftp://ftp.rarlab.com/rar/unrarw32.exe. This is an self extracting archive that contains “unrar.exe”.

You only need to manipulate the “$list” variable: specify all source directories and destination directories you need to extract.

In my case this is the result:

image

2. “Patch”

This script manipulates all neseccary files.

You need to have them all in a dedicated directory. In my case everything is located under “I:Learning”. This directory is the entry point for the other scripts. In this directory all base and differential VHDs must be located.

“Patch” modifies:

  • config.xml => replace VHD paths
  • <machine-guid>.exp => replace VHD paths
  • <name>.vhd / <name>.avhd => replace VHD paths

First the “Patch” script scans the root path (e.g. “I:Learning”) and all sub directories. It saves all VHD file names.

The next steps are to open the files specified above and replace all VHD paths (“c:program files…”) with the correct paths (“I:Learning…”).

For “config.xml” und “<machine-guid>.exp” the script creates backup files with the same name and additional “.bak” extension. If you run the script twice the backup will be restored before processing.

For “<machine-guid>.exp” another file will be creates: “<machine-guid>.exp.ik”. This file is used later for patching the virtual machine in Hyper-V.

3. “ImportVMs”

This script imports the MS Learning Machines to Hyper-V using WMI (see http://social.technet.microsoft.com/Forums/en-US/winserverClustering/thread/a4e0d12d-534c-41f6-8038-4e8a7dbbba15).

image

It imports every machine found in the sub directories of the given machine root: “I:Learning”

4. “mountVHDs”

You maybe need to mount the VHDs after importing.

This is a part of the “Classroom Setup Guide” for one training:

image

In my case this happens for all machines!!! – In case of course no. “10174” (SharePoint Config and Admin) you would have to pathc 15 machines with about 20 VHD files. You would have to repeat mounting the VHDs on every classroom machine!!! – NO WAY!

image

While importing the machines you get this event log entries in the Hyper-V VMMS/Admin event log:

  1. Import task failed to fix up connection information for connection ‘I:Learning10174Drives10174A-SP2010-WFE1-FINALVirtual Hard Disks10174A-SP2010-WFE1-FINAL.vhd’. (Event Id 18430)
  2. Import task failed to fix up connection information for connection ‘I:Learning10174Drives10174A-SP2010-WFE1-FINALVirtual Hard Disks10174A-SP2010-WFE1-Allfiles-diff.vhd’. (Event Id 18430)
  3. ’10174A-SP2010-WFE1-FINAL’: The file name ” is invalid. You cannot use the following names (LPTn, COMn, PRN, AUX, NUL, CON) because they are reserved by Windows. (Virtual machine ID FE26F0D1-B18C-440D-8CB6-792DBB6E1A5B) (Event Id 12634)
  4. ’10174A-SP2010-WFE1-FINAL’ failed to add device ‘Microsoft Virtual Hard Disk’. (Virtual machine ID FE26F0D1-B18C-440D-8CB6-792DBB6E1A5B) (Event Id 14140)
  5. Failed to import correctly the device ‘{ResourceType=21, OtherResourceType="<null>", ResourceSubType="Microsoft Virtual Hard Disk"}’ for ’10174A-SP2010-WFE1-FINAL’ (Virtual machine ID FE26F0D1-B18C-440D-8CB6-792DBB6E1A5B). Error: Invalid parameter (0×80041008) . (Event Id 18130)
  6. Import completed with warnings. Please check the Admin events in the Hyper-V-VMMS event log for more information. (Event Id 18250)

(This are examples! The paths and names will vary!)

 

image

 

The script “MountVHDs” will modify all machines in Hyper-V. ALL machines!! Be very carefull!! Again: Don’t use the scripts in a production environment!!!

To execute this script you need to install the PowerShell Hyper-V module: http://pshyperv.codeplex.com/

The script opens every machine. Than it searches in the MS Learning Root (“i:learning”) for the file “<machine-guid>.exp.ik”. If there is such a file the script modifies the virtual machine and mounts the VHDs as configured in the “EXP.IK” file.

For me it works perfectly! – Now I can set up my classroom server in few minutes!

Here you can download the scripts: http://pscst.codeplex.com – Please feel free to improve them – and to send me your improvements!!!

3 Responses to “For MCTs: Classroom Setup Tools for MS Learning Hyper-V machines”

  1. Kaya

    Hi I was so happy to find finally a solution to deploy MCT Hyper-V VHD’s !!! I tried out with Course 10131A, the first script “unpack” i didn’t used, because i unpack the files with our Deployment Software to the original Path (C:Program FilesMicrosft Learning….) the next script i used was your “patch” script, where i only changed the first $path = “C:Program FilesMicrosft Learning”, the rest i left like delievered. it worked but with some errors, and i got the following “new files” : 10231A-NYC-DC1-Allfiles-01.vhd.ik and config.xml.bak, the original config.xml and the {guid}.exp has the right paths listed…. After i took the VM-Import script and also i changed only the firs line $Path (again to C:Program FilesMicrosft Learning), and it imported my machines without any errors, but only with the Allfiles.vhd. At least i used the last of your scripts “mountVHD” with some errors or infos like this (VM: 10231A-NYC-DC1-06 skipped) and the VM had still only the allfiles.vhd…when i know a look to the config.xml.bak, the Files and location are listed on the right way, but when i take a look to the new {GUID}.exp file the first path is empty and only the path to the allfiles.xml is listed, when i manually fill out the firs location of the first vhd( example: 10231A-NYC-DC1-01.vhd) then the VM is correctly imported. What iam doing wrong? do i need to modify the “patch” script more then i explained above??? do i need the Pre Import script wich is coming with MCT Courses? Thanks in advance for your help

    Reply
  2. Clinton

    Good day Ingo,

    I am very impressed with your “For MCT’s: Classroom Setup Tools for MS Learning Hyper-V machines”. I am an MCT, and MCITP: Enterprise & Server Administrator; I just wish I had found your Blog months ago it have been of great help. The problem I that I am struggling to solve is with the mountVHD.ps1 Script. All the other Scripts I was able to get working, Unpack.ps1, Patch.ps1, ImportVMs.ps1. But I have tried all I know about Powershell and Hyper-V 3.0 that ship with Windows 8 Pro x64.

    I Errors that Hyper-v is not Installed, I get issues with the “Import-Module” and the “Get-VM”

    If it is possible would you be able to help me? And the specific problem I am having is with Course 10174B. I have done the Manual Install
    “…repeat mounting the VHDs on every classroom machine!!! – NO WAY!”
    Yes way, I have DONE that exercise 6 times over and the Download from the MCT Website… :_(

    I get Errors in the follwing Modules when Importing: Hyper-V Error – 10174A-CONTOSO-DC-F, Hyper-V Error – 10174A-SP2007-WFE1-F, Hyper-V Error – 10174A-SP2007-WFE1-G, Hyper-V Error – 10174A-SP2010-WFE1-A, Hyper-V Error – 10174A-SP2010-WFE1-B, Hyper-V Error – 10174A-SP2010-WFE1-C,
    Hyper-V Error – 10174A-SP2010-WFE1-D, Hyper-V Error – 10174A-SP2010-WFE1-E, Hyper-V Error – 10174A-SP2010-WFE1-FINAL.

    I was kind of hoping that the “Quicker” method that you designed and then Importing and Mounting with these Script files would possibly have helped. And On the Last Script File I have run into the Issue as stated above.

    All or any help you are able to give me would be greatly appreciated.

    Thanking you in advance.
    Clinton

    Reply
  3. Clinton

    Good day Ingo,

    I am very impressed with your “For MCT’s: Classroom Setup Tools for MS Learning Hyper-V machines”. I am an MCT, and MCITP: Enterprise & Server Administrator; I just wish I had found your Blog months ago it have been of great help. The problem I that I am struggling to solve is with the mountVHD.ps1 Script. All the other Scripts I was able to get working, Unpack.ps1, Patch.ps1, ImportVMs.ps1. But I have tried all I know about PowerShell and Hyper-V 3.0 that ship with Windows 8 Pro x64.

    I Errors that Hyper-v is not Installed, I get issues with the “Import-Module” and the “Get-VM”

    If it is possible would you be able to help me? And the specific problem I am having is with Course 10174B. I have done the Manual Install
    “…repeat mounting the VHDs on every classroom machine!!! – NO WAY!”
    Yes way, I have DONE that exercise 6 times over and the Download from the MCT Website… :_(

    I get Errors in the following Modules when Importing: Hyper-V Error – 10174A-CONTOSO-DC-F, Hyper-V Error – 10174A-SP2007-WFE1-F, Hyper-V Error – 10174A-SP2007-WFE1-G, Hyper-V Error – 10174A-SP2010-WFE1-A, Hyper-V Error – 10174A-SP2010-WFE1-B, Hyper-V Error – 10174A-SP2010-WFE1-C,
    Hyper-V Error – 10174A-SP2010-WFE1-D, Hyper-V Error – 10174A-SP2010-WFE1-E, Hyper-V Error – 10174A-SP2010-WFE1-FINAL.

    I was kind of hoping that the “Quicker” method that you designed and then Importing and Mounting with these Script files would possibly have helped. And On the Last Script File I have run into the Issue as stated above.

    All or any help you are able to give me would be greatly appreciated.

    Thanking you in advance.
    Clinton

    Reply

Leave a Reply