Failover of persistent desktops using SRM and View 4.6

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 Set-Cred ($File) {
    $Credential = Get-Credential
    $credential.Password | ConvertFrom-SecureString | Set-Content $File
}

Set-Cred c:\tmp\credenials.cred

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:

Function Get-Cred ($User,$File) {
    $password = Get-Content $File | ConvertTo-SecureString
    $credential = New-Object System.Management.Automation.PsCredential($user,$password)
    $credential
}

# Add the snapins needed for PowerCLI and View PowerCLI if they are not loaded

if (!(get-pssnapin -name VMware.VimAutomation.Core -erroraction silentlycontinue)) {    
    add-pssnapin VMware.VimAutomation.Core
}

if (!(get-pssnapin -name VMware.View.Broker -erroraction silentlycontinue)) {    
    add-pssnapin VMware.View.Broker
}

# vCenter Details
$VC = "MyvCenter.MyDomain.com"
$VCUser = "Administrator"
$CredFile = "c:\tmp\credenials.cred"

$creds = Get-Cred $VCUser $CredFile

# New Pool Details
$PoolID = "New_SRM_Pool"
$DisplayName = "SRM Pool"
$Description = "This pool has been automatically created by the PowerCLI Script"

# List of VMs to add to the pool
$ListOfVMs = "VIEWDesktop01", "VIEWDesktop02", "VIEWDesktop03", "VIEWDesktop04"

# Domain of the user accounts
$Domain = "MyDomain.Com"

# Users who can access the pool
$ListofUsers = "Admin01", "view-srm-user-2", "view-srm-user-3", "view-srm-user-4"

# Connect to vCenter
Write-Host "Connecting to the VI Server"
Connect-VIServer $VC -credential $creds

# Create the list of VM Id's because of the way the View cmdlets work !
Write-Host "Retrieving VM Ids"
[String]$VDIArray = ""
Get-VM $ListOfVMs | Foreach {
    $VDIArray += "$($_.id);"
}
$VDIArray.TrimEnd(";") | Out-Null

# Create the pool
Write-Host "Adding Pool $Pool_Id"
Add-ManualPool -vc_name $VC -Pool_Id $PoolID -displayName $DisplayName -description $Description -disabled:$true -vm_id_list $VDIArray

$ListofUsers | Foreach {
    Write-Host "Adding user $_"
    Add-PoolEntitlement -pool_id $PoolID -sid (Get-User -name $_ -domain $domain).sid
}

12 thoughts on “Failover of persistent desktops using SRM and View 4.6

  1. Baz

    Very good article indeed. I will be using this for my View 6.1 deployment using persistent Desktops. Do you know if any of the PowerShell commands referenced above are now deprecated in the new Horizon 6 environment?

  2. Jeff Miller

    My setup is as follows
    One VDI per pool
    One user per pool
    One user per VDI

    How would you script this setup? I need 35 pools, 35 desktops, 35 users.
    Also is there a way to export this info from production? I need a way to keep this script current to reflect any changes to production.
    Thanks in advance

  3. tanwk

    Am also looking at dedicated linked clone desktop with the ability to do local mode.

    With linked clone you will need a script to recorrect all the storage path which was hard recorded.

    To help understand would assume your e.g. above is based on full clone desktop in same domain?

  4. Virtu-Al

    Yeah exactly, replicate the master image and then create the linked clones as part of the script. Not sure i know enough about View to answer your other question.

  5. Tom

    i do not understand it, if you protect the “golden image” you should recreate all the link clones with the view manager at the dr side so the it could not be integrated with SRM except replicating the master image.
    i am asking about dedicated desktops pools which based on link clones for system disks, is there any way to protect those desktops with SRM?

  6. Virtu-Al

    In this case they were the same domain but im sure you could use Invoke-VMScript to change the domain of the Desktop VMs if needed.

  7. Fred

    But how about the domains of the View Desktop servers?

    How to add the Desktop VMs to the domains in the recovery site?

    thanks.

  8. Pingback: Top 5 Planet V12N blog posts for week 23 | Download VDI Solutions

Leave a Reply to Tom

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.