Getting Started with PowerCLI for VMware Cloud Disaster Recovery

June 25, 2022

Introduction

The recent (v22) release of VMware Cloud Disaster Recovery introduces a new RESTful API for monitoring and retrieving information about protected VMs, protected sites, protection groups, snapshots, cloud file systems, and recovery SDDCs.

With this new API, we are going to introduce a new set of PowerShell cmdlets to monitor VMware Cloud Disaster Recovery (VCDR).

Special thanks to Max Daneri for putting this content together for sharing here.

cmdlets available

  • Connect-VCDRServer
    • Establishes a connection to a VCDR Server system
  • Disconnect-VCDRServer
    • Closes the connection to a VCDR Server system
  • Get-VCDRCloudFileSystem
    • List any cloud file systems (SCFS)
  • Get-VCDRProtectedSite
    • List any protected sites
  • Get-VCDRProtectionGroup
    • List any protection groups (PGs) associated with an individual cloud file system
  • Get-VCDRSnapshot
    • List any snapshots in a specific protection group
  • Get-VCDRProtectedVm
    • List of any protected VM associated with an individual cloud file system
  • Get-VCDRRecoverySddc
    • List any Recovery SDDC 

Getting Started

Let’s take a look at each of these cmdlets and how they can be used to gather information about your VCDR instances.

Getting a token

The first step to getting access to VCDR is to get a VMC Refresh Token. If you already have one you can skip the next topic

VCDR is a VMware Cloud Service and like any other service is using a user Refresh Token to authenticate.

This can be done in 3 simple steps:

1) Login to your VMC Console https://vmc.vmware.com

image-20220601180519-1

2) Go to API Tokens – > GENERATE TOKEN

  • You can set the Token TTL as much as you like
  • Select at least Organization Role of Organization Member
  • Select the Service Role VMware Cloud DR
    • Note: The VMware Cloud DR Admin requirement will be dropped in a future release for a simple Auditor role.

image-20220601183756-2

3) Hit Generate and Save your token as this cannot be retrieved again.

image-20220601184239-3

Import the Cmdlets

Open your PowerShell tool and install the VMware.VCDRService module:

  • You can use PowerShell Core (Any OS) v7.1.x or greater or PowerShell Desktop (Windows)  v5.1 or greater.
  • You can open your PowerShell command line pwsh for .net core or PowerShell for Desktop Windows version

PS> Install-Module -Name VMware.VCDRService

image-20220601184649-4

Connect to VMware Cloud DR service

The first CmdLets to use is Connect-VCDRServer using the VCDR URL for the Orchestrator and the API refresh token previously generated.

PS> Connect-VCDRServer -server "<your_VCDR_FQDN>" -token "<yourToken>"

image-20220601185202-5

  • NOTE: each cmdlet has a "-server" property where the variable can be used when multiple VCDR Servers are connected.

The Connect-VCDRServer result can be assigned to a variable and used as a parameter when more than one VCDR service is available. For example, you can connect to multiple VCDRs available in different Regions and use the variable filled by Connect-VCDRServer to select a specific VCDR instance.

Explore the Cmdlets

The following command is Get-VCDRCloudFileSystem. This cmdlet returns a list of all Cloud File Systems deployed in a specific region or, more precisely, all SCFS associated managed by the VCDR Orchestrator you are using.

image-20220601132929-1

In this case, we have two Cloud File Systems.

Usually is convenient to assign the result of this Cmdlet to a variable so can be used as a parameter for other Cmdlets.

For example, using the $cloudFileSystem variable(array) I can invoke Get-VCDRProtectedSite with the first entry [0]

In this case, the response is the list of any Protected Site covered by cloud-backup-2-GSS Cloud File System.

image-20220601133325-2

NOTE: The -CloudFileSystem parameter can also be passed through a pipeline in this case $cloudFileSystem[0]|Get-VCDRProtectedSite.

Using the same $cloudFileSystem variable you can get the list of Protection Groups associated with the other Cloud File System at entry [1]  cloud-backup-1-TS including health state and used space

image-20220601133616-3

NOTE: The -CloudFileSystem parameter can be an array of CloudFileSystem and the result will be the sum of the result of each CloudFileSystem.

Samples

Here is a sample script that can give you all the available information regarding your VMware Cloud Disaster Recovery configuration:

# set environment and local values for your site
Install-Module -Name VMware.VCDRService
$token="your Generated VMC API token"
$server="vcdr-aaa-bbb-ccc-ddd.app.vcdr.vmware.com"

# connect to VMware Cloud DR instance
$VCDR=Connect-VCDRServer -server $server -token $token

# identify any deployed SDDC(s)
$RecoverySDDC=Get-VCDRRecoverySDDC

#identify the connected SCFS repositories
$SCFS=Get-VCDRCloudFileSystem

#return any Protection Site(s) for the first CloudFileSystem returned
$ProtectedSites=Get-VCDRProtectedSite -CloudFileSystem $SCFS[0]

#return any Protection Group(s) for the first CloudFileSystem returned
$PGs=Get-VCDRProtectionGroup  -CloudFileSystem $SCFS[0]

#return any snapshots for the list of PGs (Protection Groups) returned
$Snapshots=Get-VCDRSnapshot -ProtectionGroups $PGs

# identify the VMs protected for the first CloudFileSystem identified
$VMs=Get-VCDRProtectedVm -CloudFileSystem $SCFS[0]

# cleanly exit
Disconnect-VCDRServer -server $VCDR

Summary

PowerCLI for VMware Cloud Disaster Recovery brings us the ability to view helpful information and the status of different VCDR components. This is the first release of VCDR that includes an API. The RESTful API are not mature yet, and the same is true for the PowerCLI, today are not officially supported but we are committed to improving and expanding both API and Cmdlets to cover any feature today available in VCDR.

Links

 

 

Filter Tags

DRaaS PowerCLI VMware Cloud Disaster Recovery VMware Cloud on AWS Blog Feature Walkthrough Disaster Recovery Intermediate Manage