Querying SRM for Protected VMs with PowerCLI

I was recently asked how to query SRM for protected VMs and I decided it would make a good quick blog post. There is a great post here on using PowerCLI with SRM, but it doesn’t show the information to return per virtual machine information by default. Needs a bit more.

All it returns is a SRM-based virtual machine ID which doesn’t relate to what a user is probably looking for (a virtual machine name). So it needs a few more simple steps. The following script which can be found on my GitHub page here that does the following things:

  1. Connects to a vCenter
  2. Connects to SRM
  3. Creates a log folder with a time stamp in the name
  4. Iterates through each Protection Group
  5. Logs every virtual machine in that protection group

Below is an example log file:

________________________________________________________________________

Pure Storage SRM Protected VM Inquiry Script
========================================================================
******************************Next Protection Group********************************
========================================================================
The following 30 virtual machines are in the Protection Group named SRM Demo
Virtual Machine list:
SRM VM28
SRM VM29
SRM VM21
SRM VM3
SRM VM10
SRM VM9
SRM VM5
SRM VM20
SRM VM8
SRM VM27
SRM VM19
SRM VM7
SRM VM24
SRM VM6
SRM VM4
SRM VM23
SRM VM25
SRM VM26
SRM VM22
SRM VM42
SRM VM44
SRM VM46
SRM VM41
SRM VM43
SRM VM47
SRM VM50
SRM VM48
SRM VM49
SRM VM45
SRM VM1
========================================================================
******************************Next Protection Group********************************
========================================================================
The following 30 virtual machines are in the Protection Group named SRM PG2
Virtual Machine list:
SRM VM57
SRM VM37
SRM VM59
SRM VM18
SRM VM56
SRM VM60
SRM VM2
SRM VM31
SRM VM38
SRM VM58
SRM VM34
SRM VM15
SRM VM55
SRM VM36
SRM VM30
SRM VM40
SRM VM51
SRM VM32
SRM VM17
SRM VM13
SRM VM11
SRM VM54
SRM VM33
SRM VM16
SRM VM35
SRM VM14
SRM VM52
SRM VM12
SRM VM53
SRM VM39

2 Replies to “Querying SRM for Protected VMs with PowerCLI”

  1. When I use the sciprt, I see Protection Groups Names twice in the reports ? Is that something, we need to check ?

    1. My guess is that you are in enhanced linked mode. Both SRM servers carry the protection groups in their databases, so it is possible both return a listing. Since they are connected via SSO a single query goes to them both. But that is just a guess

Leave a Reply

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.