My name is Ajay Kumar and I am a developer on the Remote Desktop Virtualization (RDV) team. In Windows Server 2012 (WS2012) we introduced a new feature for VDI deployments, which allows admins to automatically create multiple virtual machines (VMs) using a single image as input and deploy them as a virtual desktop collection. These virtual desktop collections, where VMs are automatically created by Remote Desktop Services (RDS) are referred to as managed virtual desktop collections.
In a previous blog post my colleague Omair Gillani has already demonstrated how an admin can create a Remote Desktop Services deployment and a managed virtual desktop collection using Windows PowerShell. In this blog post I will share some more details about managed virtual desktop collections and how an admin can use single Master VM to create and update hundreds of VMs in a managed virtual desktop collection (Single Image Management).
Master (Gold) VM in Managed Virtual Desktop Collections
A Master or Gold VM is formally referred to as “virtual desktop template” in the WS2012 Server Manager UI console and the cmdlets in Remote Desktop Services module for Windows PowerShell. It is an input to the managed virtual desktop collection creation process that allows an admin to manage a virtual desktop collection. The Master VM is created and managed by the admin and it specifies the hardware properties and software contents of all the automatically created VMs in that managed virtual desktop collection. For example, if the master VM is assigned 2GB of RAM, then each of the automatically created VMs in the managed virtual desktop collection will be assigned 2GB RAM.
In this section, I will describe the various supported options and requirements for the Master VM.
- Virtual Hard Disk
- The Master VM can only have one virtual hard disk (VHD) attached to it; more than one VHD attached to the Master VM is not supported.
- The VHD attached to the Master VM must have either a Windows 7 SP1 or Windows 8 image in sysprep generalized state.
- A diff disk chain attached to the Master VM as its VHD is supported.
- Although the VHD can have more than one logical partition defined in it, it can have only one Windows OS image installed in it.
- Memory: If the Master VM is configured with static memory, it must have at least 1024 MB as startup RAM. If the Master VM is configured with dynamic memory, the maximum RAM must be at least 1024 MB.
- Network: The Master VM must have a network adapter connected to a virtual switch on the hyper-V server.
- Snapshots on Master VM: A Master VM can have one or more snapshots. If there are multiple snapshots created on the Master VM, the current (“Now”) state of the VM will be used to automatically create the VMs in a managed collection. This allows admins to manage the Master VM more efficiently. For example, an admin can take snapshot on the Master just before running sysprep generalize command and after the sysprep is complete, the Master VM can be used for creating a managed virtual desktop collection.
- Domain connectivity: Since the VMs in a managed collection are automatically joined to the specified domain, admins must ensure that the domain controller is reachable through the virtual switches on all the hyper-V servers.
- Export: During the managed virtual desktop collection creation process, the first step that Remote Desktop Services takes is to export the Master VM. This export process creates a copy of the Master VM’s current h/w settings and the VHD attached to the Master VM at the admin specified storage location. The automatically created VMs and the VHDs attached to these VMs are based upon this copy of the Master VM. The original Master VM is never modified by Remote Desktop Services. Once the export process is complete, admin can continue using it.
- Two or more collections can share a Master VM. Each time a new collection is created or updated, the Master VM is exported again. So each managed collection has its own copy of a Master VM.
Rolling Out Updates to a Pooled Virtual Desktop Collection
To automatically update all the VMs in a pooled virtual desktop collection, the admin has to first apply the desired changes to the Master VM manually (for example, increase RAM from 1GB to 2GB or apply a software patch). Once the Master VM has been updated the admin can use either WS2012 Server Manager console or Windows PowerShell to push the updates to all the VMs in a pooled managed collection.
To update the VMs in a pooled virtual desktop collection using the WS2012 Server Manager console please follow these steps:
- Log on to the connection broker server as a domain user account which is also an admin on the connection broker server. Server Manager will start automatically. If it does not automatically start, click Start, type servermanager.exe, and then click Server Manager.
- In the left pane, click Remote Desktop Services, and then click Collections.
- Select the collection node to which you wish to roll out the update
- Click Tasks on Virtual Desktops list view, and then click Recreate All Virtual Desktops. This will launch the Recreate All Virtual Desktops wizard.
- Select the updated Master VM that you want to use to roll out the updates and click Next.
- Specify the User Logoff Policy and click Next.
- On the Confirmation page, click Create.
Here is an example of the Update-RDVirtualDesktopCollection cmdlet which can also be used to push updates to the VMs in a managed pooled virtual desktop collection:
PS C:> import-module RemoteDesktop
PS C:> $time = Get-Date
PS C:> Update-RDVirtualDesktopCollection -CollectionName MyPooledCollection -VirtualDesktopTemplateName masterVm -VirtualDesktopTemplateHostServer Host1.contoso.com -StartTime $time.AddDays(1) -ForceLogoffTime $time.AddDays(2)
During the update process, The Master VM is exported again and a new Master VM copy is created on the collection storage. All the VMs in the managed pooled virtual desktop collection are recreated by the Remote Desktop Services using the newer copy of the Master VM. Once the update process is complete and all the VMs in the collections have been successfully recreated, the Remote Desktop Services delete the old copy of the Master VM from the storage.
I would like to clarify that although a Master VM can be used to automatically create VMs in both types of collections (pooled and personal virtual desktop collections) but it can be used to update only the pooled virtual desktop collection VMs. Master VM cannot be used to push updates to existing VMs in a personal virtual desktop collection.
User Session Aware Update
The update process for managed pooled virtual desktop collection provides three options to the admin to decide whenhow the updates will be applied to a managed pooled virtual desktop collection:
- Apply update gracefully in a time period
- Apply update forcefully now
- Apply update forcefully at a schedule time
If an admin selects the option a) and provides a time period, the update process for pooled virtual desktop becomes aware of the active user sessions on the VMs in the pooled virtual desktop collection. Only the unused VMs are updated during this time period. If a user logs off on his own before the end of the admin specified time period, the VM will be automatically queued up for the update process. At the end of the time period the users, which are still active on non-updated VMs, are forcefully logged off from the non-updated VMs and the update process for these remaining VMs will start.
All the VMs (updatednon-updated) in the collection are available for the user connections during this time period, except for the VMs on which update is in-progress.
In the previous section I have already given a PowerShell example for the option a). Here is a PowerShell example for the option b), which starts updating the VMs in the collection forcefully as soon as the Update-RDVirtualDesktopCollection cmdlet is executed:
PS C:> import-module RemoteDesktop
PS C:> Update-RDVirtualDesktopCollection -CollectionName MyPooledCollection -VirtualDesktopTemplateName masterVm -VirtualDesktopTemplateHostServer Host1.contoso.com
Here is a PowerShell example for the option c), which starts updating the VMs in the collection forcefully at the specified time:
PS C:> import-module RemoteDesktop
PS C:> $time = Get-Date
PS C:> Update-RDVirtualDesktopCollection -CollectionName MyPooledCollection -VirtualDesktopTemplateName masterVm -VirtualDesktopTemplateHostServer Host1.contoso.com -ForceLogoffTime $time.AddDays(2)
In all of the three examples above, the input values of cmdlet parameters -CollectionName, -VirtualDesktopTemplateName and –VirtualDesktopTemplateHostServer represent the variables that are specific to a deployment.
- “MyCollectionName” is the name of the virtual desktop collection to which updates will be applied.
- “masterVm” is the name of the Master VM which contains the updates.
- “Host1.contoso.com” is the name of the hyper-V server that is hosting the Master VM named “masterVm”.
While trying these example cmdlets, please replace these names with the appropriate values in your deployment.
To summarize, the managed virtual desktop collections in WS2012 make it really easy for the admin to create and manage hundreds of VMs using a single Master VM as the template. In this blog post I have tried to describe the role of a Master VM in a managed virtual desktop collection and the supported options for a Master VM. I have also described how an admin can use Master VM to roll out updates to managed pooled virtual desktop collections. I hope you will find it useful while creating and updating VMs in your managed virtual desktop collections.
Looking forward to your questions and feedback,