If you read the part 1 of this series about the SRM module, you should now be able to connect to Site Recovery Manager from within Powershell and have the $defaultsrmservers variable at your mercy. Meaning you are ready to start looking at how to use the module itself.

Find your way around with Get-Member

Before diving into the features of the module we need to get back to a few basics to make sure you don’t get lost later on. If you are not familiar with the Get-Member cmdlet, now is the time to get stuck in as it is the best way to find out what you can do when you look into the properties and methods of $defaultsrmservers (or any other Powershell object for that matter).

Protect Your Data with BDRSuite

Cost-Effective Backup Solution for VMs, Servers, Endpoints, Cloud VMs & SaaS applications. Supports On-Premise, Remote, Hybrid and Cloud Backup, including Disaster Recovery, Ransomware Defense & more!

Methods and properties

Method

A method is an action that can be performed on an object with or without arguments passed to it.

For instance, the object ‘car’ has a method ‘StartEngine()’ that takes no argument and a method ‘Turn(“”)’ that takes either “right” or “left” as an argument.

Download Banner

Properties

A property can contain a value of various types.

To continue on the car analogy, the object ‘car’ has a property ‘Color’ with a value ‘Green’.

ExtensionData

Now, with the SRM module, the interesting stuff is located in the ExtensionData property of the $defaultsrmservers variable. Like we said, see for yourself with the Get-Member cmdlet and have a look at what can be done.

Site-Recovery-Manager

The standard output of the Get-Member cmdlet contains another property called Definition which provides information about the type of object that is returned by the method, if it needs or not argument(s) and what type… I purposely scrapped this property in the above to make it more readable on the blog. However, the Definition field of Get-Member is very useful to know how to use methods at a glance.

Let’s take two methods from the above as an example.

  • The GetPairedSite() method below will generate an object of type VMware.VimAutomation.Srm.Views.SrmLocalSiteInfo (first part of the definition property) and does not take any argument (because there is nothing between the parenthesis)

GetPairedSite Method VMware.VimAutomation.Srm.Views.SrmRemoteSite GetPairedSite()

  • However, the LoginLocale() method will generate no output and requires three arguments of type string.

LoginLocale Method void LoginLocale(string username, string password, string locale)

To show an example, try the GetPairedSite() method (which does not take any argument) on $DefaultSrmServers.extensiondata.

Site-Recovery-Manager

Where are they

As you can see there is no Get-ProtectionGroup or Get-ProtectedVM type of cmdlet available in this module. Everything you will need is somewhere in the properties of $DefaultSrmServers.extensiondata, it’s a bit more work but that’s what makes it very interesting for Powershell geeks. The methods available in $DefaultSrmServers.extensiondata itself are mainly related to SRM server and not about the actual protection or recovery of your workload.

To get cracking with these, we will need to work with the methods available a few levels below.

Protection of workloads: $DefaultSrmServers.extensiondata.Protection….
Recovery of workloads: $DefaultSrmServers.extensiondata.Recovery….

The last property available in “at the root” is $DefaultSrmServers.extensiondata.Storage. It is only used to rescan the storage devices if you work with array based replication (ABR).

In the diagram below you can get a better idea of what I mean. It will help you quickly find whatever you are after without going on a treasure hunt (although it’s fun). This diagram is taken from the excellent API developer’s guide that I mentioned in part 1 and in the next chapter.

Site-Recovery-Manager

API developer’s guide

It kind of sounds like I am repeating myself but this resource is so good that I am making a chapter out of it. It is not that often that a nice clear and detailed document exists when working with an API. So credit given where credit is due. Follow this link to download the guide.

There is some interesting explanation at the beginning but the interesting stuff starts on page 8 with the list of API operations. Then you scroll through the guide, you will see that all the methods and properties that you see in Powershell inside the $DefaultSrmServers.ExtensionData property are mentioned here with what they do.

Then on to page 29 in the Logical Order API Usage chapter, you will find details about the different methods and properties, what they are/do, what argument to use, what the error (Faults) can be … This kind of information is really useful when writing a script or a function because you need to cover the different possible scenarios.

Site-Recovery-Manager

Next

Stay tuned for the next part of this how to that will show you how to gather intelligence and interact with the Site Recovery Manager module.

Follow our Twitter and Facebook feeds for new releases, updates, insightful posts and more.

Rate this post