ADVERTISE HERE

Failover of persistent desktops using SRM and View 4.6

Title: Failover of persistent desktops using SRM and View 4.6
Author(s): (VIRTU-AL) Alan Renouf
Target Audience: Technical - Intermediate
Current Revision:
First Published: 20 June 2011
Products: VMware
UID: XD10420

Recently I came across an interesting use case for VMware Site Recover Manager (SRM) and View 4.6, specifically the View 4.6 PowerCLI cmdlets

Punchy Text: 

Recently I came across an interesting use case for VMware Site Recover Manager (SRM) and View 4.6, specifically the View 4.6 PowerCLI cmdlets

Alan Renouf is a community peer for VMware PowerCLI, Virtu-Al.Net.  In 2009, he was named a vEXPERT by VMware.  Alan's main focus is to teach and help other VMware admins automate their VMware infrastructures and make their lives easier through automation.
www.virtu-al.net.


With View 4.6 becoming largely adopted by many businesses recently I came across an interesting use case for VMware Site Recover Manager (SRM) and View 4.6, specifically the View 4.6 PowerCLI cmdlets.

Imagine this scenario (and this is just one example of why you would do this)….

Scenario

You have virtualised your desktops because you want to gain the benefit of having an agile desktop, a desktop which you can use on any PC, Thin Client, iPad, iPhone, Tablet etc, everyone from the cleaner to the MD now uses a virtual desktop – including you – the system administrator.

One day there is a Disaster, a plane falls out of the sky into your datacenter and wipes out everything – PANIC !

But wait, you have SRM, your key servers have been moved to your recovery site, a replicated datacenter in a neighboring town and your data is replicated on a regular interval, VMware to the rescue again !

Just one thing remains, you now need to re-create your workstations in your recovery site, start deploying the first few to the rest of your team and install all the admin applications you need to bring your systems back up to a working state so that the users can gain access to their recovered system.

This was just the same scenario a company recently had, they had specific view desktops for the management of their systems, these were assigned as persistent desktops and contained the key apps and management tools needed to manage the infrastructure and help desk system.

So how can SRM and View be used together to help ?

Solution

With the customer keen to keep the persistent desktops they needed we were able to use SRM to protect these persistent desktops and replicate them to the recovery site as part of the recovery plan, once on the recovery site these persistent desktops would need to be re-added to the View server already configured on the recovery site, a pool would need to be created, the desktops added to the pool and permissions added for the admins to be able to access these desktops.

A perfect case to add a custom step to the SRM recovery plan which calls a View PowerCLI script using PowerShell Remoting as discussed in my previous post, the below shows an example of this custom step:

SRMRecoveryStep

Firstly I stored the credentials used to connect to the remote view server in a secure credentials file using the below simple functions – I'm sure there is probably a better way so please do use your own method here:

Function

The script used to facilitate the pool and all other areas needed is as seen below, this is the script used in the recover plan:

01 Function Get-Cred ($User,$File) {
02     $password = Get-Content $File | ConvertTo-SecureString
03     $credential = New-Object System.Management.Automation.PsCredential($user,$password)
04     $credential
05 }
06  
07 # Add the snapins needed for PowerCLI and View PowerCLI if they are not loaded
08  
09 if (!(get-pssnapin -name VMware.VimAutomation.Core -erroraction silentlycontinue)) {    
10     add-pssnapin VMware.VimAutomation.Core
11 }
12  
13 if (!(get-pssnapin -name VMware.View.Broker -erroraction silentlycontinue)) {    
14     add-pssnapin VMware.View.Broker
15 }
16  
17 # vCenter Details
18 $VC = "MyvCenter.MyDomain.com"
19 $VCUser = "Administrator"
20 $CredFile = "c:\tmp\credenials.cred"
21  
22 $creds = Get-Cred $VCUser $CredFile
23  
24 # New Pool Details
25 $PoolID = "New_SRM_Pool"
26 $DisplayName = "SRM Pool"
27 $Description = "This pool has been automatically created by the PowerCLI Script"
28  
29 # List of VMs to add to the pool
30 $ListOfVMs = "VIEWDesktop01", "VIEWDesktop02", "VIEWDesktop03", "VIEWDesktop04"
31  
32 # Domain of the user accounts
33 $Domain = "MyDomain.Com"
34  
35 # Users who can access the pool
36 $ListofUsers = "Admin01", "view-srm-user-2", "view-srm-user-3", "view-srm-user-4"
37  
38 # Connect to vCenter
39 Write-Host "Connecting to the VI Server"
40 Connect-VIServer $VC -credential $creds
41  
42 # Create the list of VM Id's because of the way the View cmdlets work !
43 Write-Host "Retrieving VM Ids"
44 [String]$VDIArray = ""
45 Get-VM $ListOfVMs | Foreach {
46     $VDIArray += "$($_.id);"
47 }
48 $VDIArray.TrimEnd(";") | Out-Null
49  
50 # Create the pool
51 Write-Host "Adding Pool $Pool_Id"
52 Add-ManualPool -vc_name $VC -Pool_Id $PoolID -displayName $DisplayName -description $Description -disabled:$true -vm_id_list $VDIArray
53  
54 $ListofUsers | Foreach {
55     Write-Host "Adding user $_"
56     Add-PoolEntitlement -pool_id $PoolID -sid (Get-User -name $_ -domain $domain).sid
57 }

Spotlight:

VMware Documentation Downloader v11.08.30

Updated for vSphere 5 - A free tool for those on the move who need information FAST

vSphere 5 License Entitlement Changes

See what has changed in the license entitlement in vSphere 5?

Thin Client vs Zero Client

The differences between Thin and Zero desktop clients for VDI

Technology Exchange: