Creating Provisioning Services & XenDesktop Virtual Desktops on Windows Server 2012 Hyper-V using PowerShell!

Share Button

Click to download: WS2012_HyperV_PVS_XenDesktop_StreamedVM_Setup_Wizard.ps1

I was recently asked to do a hypervisor performance comparison using LoginVSI against Windows Server 2008 R2 SP1 Hyper-V 2 and the newly released Windows Server 2012 Hyper-V 3.  For this scenario we would need to spin up a number of virtual desktops on Hyper-V 2.0 and Hyper-V 3.0 using Citrix Provisioning Services and Citrix XenDesktop for the connection broker.  This was a very exciting project for me, but seeing that Windows Server 2012 is not yet supported for use with PVS or XenDesktop, I had to be a bit creative in the virtual machine creation process. Additionally, XenDesktop will treat these virtual machines as physical devices and will not have any power management capabilities.

Seeing that Windows Server 2012 now ships with PowerShell v.3, I figured the task wouldn’t be too terribly difficult to tackle. I would simply need to create a template VM just as I had done for numerous XenDesktop on Hyper-V deployments, then clone this template a number of times to reach my desired desktop count.  Once the desktops were cloned, a report with all the MAC addresses could then be imported into PVS to attach to the appropriate vDisk and AD Machine accounts could be created. The last step is to create a catalog and desktop assignment group for brokering connections to the VDA through XenDesktop. Below I will cover a couple lessons learned with the initial development of the script.

For this exercise I intentionally wanted to bypass the use of System Center and create all the VMs directly from Hyper-V.  Technically System Center VMM 2012 SP1 (currently in CTP) would be able to manage the WS2012 Hyper-V boxes, but I would still have complications obtaining all the MAC addresses once created. Therefore, I decided to use an all Hyper-V/PowerShell method to export the template and repeatedly import the template.

Issue: Exporting and importing a virtual machine with a hard disk attached is problematic.
Solution: detach the disk, export the VM, import and rename the new VM, copy the detached disk to the new VM location, attach the disk to the new VM.

Issue: MAC addresses are not allocated to newly imported VMs until they are powered on.
Solution: Power on the virtual machine long enough to obtain a MAC address, then force a power off operation. At this point a MAC address has been allocated and can be retrieved and logged.

Below is a sample output, post execution:

I am also including a several minute video demonstrating the use of the powershell script and showing a virtual desktop being brokered through XenDesktop 5.6 using PVS 6.1 and Windows Server 2012 Hyper-V 3!

If you have any questions, comments, or just want to leave feedback, please do so below. Thanks for reading!

–youngtech

Share Button
  1. alexalex05-02-2013

    can I use it in 2008R2 ? and how please ,am stuck here

  2. alexalex05-02-2013

    Dear friend

    I have problems in using 2008R2 with PVS 6.1 and XenD 5.6, I saw your clip is a amazing !! I am surprise really because we are trying to use PVS but its very slow to create XD vms ,could you please help me in how to achieve this with 2008R2 HyperV we cant use 2012 ,appreciating your help and support

  3. MattMatt12-05-2012

    Can you provide any details of the testing results between 2008 r2 and 2012?

    • Dane YoungDane Young12-05-2012

      Matt,

      Not at this point. I have proposed a session for Synergy Anaheim 2013 where I will hopefully be able to talk to these results in more detail.

      Thanks
      –youngtech

  4. Tony Sanchez (Citrix)Tony Sanchez (Citrix)11-09-2012

    Great video. I have some other powershell scripts we use for large scalability testing with XD on Hyper-V. I can share those with you later on..

    • Dane YoungDane Young11-13-2012

      Excellent. Anything you can contribute, #unsupported of course, with the community would be greatly appreciated!
      Thanks,
      –youngtech

  5. Jeffrey Snover [MSFT]Jeffrey Snover [MSFT]09-09-2012

    If you had done this as a PowerShell workflow you could have created the machines in parallel! That would have been cool.

    Jeffrey Snover [MSFT]
    Distinguished Engineer and Lead Architect for Windows Server and System Center

    • Dane YoungDane Young09-09-2012

      Jeffrey!
      Thanks so much for your comment! Long time follower and fan of your work at MSFT! Keep up the good work with everything you’re doing! Watch for workflows in the next revision! 🙂 I looked into using mutithreading with start-job, but since I’m writing output to a log file, I wasn’t confident that would work so great. I’ll look for examples of workflows and see if I can adapt some samples out there. Loving PoSH 3.0, almost as much as WS2012 and SC2012!
      Cheers,
      –youngtech

Leave a Reply to Matt Click here to cancel reply.