PowerShell GUI VMware and FlashArray Snapshot Management Tool

There are a variety of methods of managing VMware objects (VMFS volumes, VMs, VMDKs and RDMs) and the underlying snapshots to recovery or clone them. But often I get asked if I have a PowerShell (PowerCLI) script to do one or all of them. I have a bunch on my GitHub, but I decided a week or so ago to put something a bit more robust together. At first I was making it a standard interactive script, but it morphed into a GUI, using combo-boxes etc:

NOTE: Please read this post in detail before use! It restores and removes VMs depending on the operation, so read this to understand what is going to happen before running it.

So, what does this tool do? A few things. It allows you to manage the follow objects:

  • VMFS
  • Virtual Machine
  • Virtual Disk (VMDK)
  • Raw Device Mapping (RDM)

At a high level, you can restore any one of these objects from a FlashArray snapshot of your choosing (or create a new snapshot). You can also spin up a copy of that object. There are a few options to change the behavior of the operation. Let’s walk through it.

Configuration

The first thing you need to do is to download the tool. You can get it here:

https://github.com/codyhosterman/powercli/blob/master/PureStorageVMwareRecoveryTool.ps1

Next make sure PowerCLI 6.3 R1 or later is installed as well as the Pure Storage PowerShell SDK 1.7 or later is installed. Now, just run the ps1 file.

This tool changes some PowerCLI variables, so run the tool as administrator.

The next step is to authenticate the vCenter and a FlashArray. Add in your vCenter credentials and your FlashArray credentials (as well as their IP or FQDN) and click connect respectively. Doesn’t matter what order you connect.

You can disconnect and connect to a new FlashArray or vCenter at anytime. In this release, connections to only one vCenter and one FlashArray at a time is supported. To connect to a different FlashArray, for instance, click disconnect and re-enter the connection info for the different array.

Once connect to both, the remaining options will populated as they become available. The first box is about what object do you want to deal with, a VMFS, a virtual machine, a virtual disk, or a RDM? Choose the proper radio button. You can always switch at any time. Furthermore, when you choose the object and go to select it, if you have a large environment, the drop-down could be huge. So there are two filters available for you; filter by VMware cluster or by object name. Choose neither, both, or just one. If you are recovering a VMFS, it will be the datastore name, for everything else, it is the VM name. The cluster drop-down will pull in all of the cluster names in your vCenter (filtered by your vCenter permissions of course).

I am going to look for a VM in my cluster named “SJ-Infrastructure” that has a name including “app”. The search is case-insensitive.

Once, chosen, click the “Get Datastores or “Get Virtual Machines” and choose the recovery object. In the next four sections, I will describe the workflow, based on first VMFS, then Virtual Machine, then Virtual Disk, and then finally RDM.

VMFS Recovery

Once, you have connected to vCenter and the FlashArray, choose VMFS as the option. This will enable the “Get Datastore” button. Depending on your filters, it will return all or a subset of the datastores in your vCenter. Choose the datastore you want. Also, choose a cluster. This will be the cluster that a copy of the datastore will be provisioned to.

The datastore option only has one workflow. Choose a snapshot and then bring up a copy of that datastore from the point-in-time of that snapshot.

Virtual Machine Recovery

Once, you have connected to vCenter and the FlashArray, choose “Virtual Machine” as the option. This will enable the “Get Virtual Machines” button. Depending on your filters, it will return all or a subset of the VMs in your vCenter. Choose the VM you want.

There are two recovery options, you can select both, neither or just one.

The behavior will be as such depending upon your selections:

  • Neither option is checked: This will bring up a copy of the datastore that the VM sits on from the snapshot you choose. The VM will then be registered from that copied datastore with the original name plus a suffix to make it unique from the original. In the first release, the VM will be added to the same cluster as the original VM. It will not be powered on, to prevent network interference.
  • Only “Replace original VM/VMDK/RDM” is selected: In this case, the copied datastore will be brought up from the chosen snapshot and the VM will be registered with a temporary name. The original VM will be deleted. The copied VM will be renamed back to the original name and powered on. It will remain on the copied VMFS.
  • Only “Storage vMotion back to the source VMFS” is selected. This will bring up a copy of the datastore that the VM sits on from the snapshot you choose. The VM will then be registered from that copied datastore with the original name plus a suffix to make it unique from the original. The VM will then be Storage vMotioned to the original datastore. If the copied datastore is then clear of any registered VMs (it should be unless someone manually put on one it) it will be unmounted, detached from all hosts and then destroyed on the FlashArray. The VM will not be powered-on to prevent network collisions.
  • Both options are selected. In this case, the copied datastore will be brought up from the chosen snapshot and the VM will be registered with a temporary name. The original VM will be deleted. The copied VM will be renamed back to the original name and powered on. The VM will then be Storage vMotioned to the original datastore. If the copied datastore is then clear of any registered VMs (it should be unless someone manually put on one it) it will be unmounted, detached from all hosts and then destroyed on the FlashArray.

Note that in the initial version, for full VM recovery only VMs that are on only one datastore will be supported. For virtual disk and RDM recovery, the VM can be spread across as many datastores as needed.

Virtual Disk Recovery

Once, you have connected to vCenter and the FlashArray, choose “Virtual Disk” as the option. This will enable the “Get Virtual Machines” button. Depending on your filters, it will return all or a subset of the VMs in your vCenter. Choose the VM you want.

Quick thanks to @ikiris for this following post, really helped me for this part:

http://blog.chrischua.net/2015/06/23/change-vmdk-uuid-using-powercli/

Once a virtual machine has been chosen, the virtual disks will be listed. This will show the virtual disk path and the size. Choose the virtual disk you want to recover.

There are two recovery options, you can select both, neither or just one.

The behavior will be as such depending upon your selections:

  • Neither option is checked: This will bring up a copy of the datastore that the virtual disk sits on from the snapshot you choose. The virtual disk will then be added from that copied datastore to the VM. The virtual disk will be given a new, unique UUID so it does not interfere with the original virtual disk . It will be added to the same virtual SCSI controller as the original disk.
  • Only “Replace original VM/VMDK/RDM” is selected: In this case, the copied datastore will be brought up from the chosen snapshot. The source virtual disk will be removed and deleted from the datastore and the recovered virtual disk will be added to the VM in the same controller as the original. It will remain on the copied VMFS.
  • Only “Storage vMotion back to the source VMFS” is selected. This will bring up a copy of the datastore that the virtual disk sits on from the snapshot you choose. The virtual disk will then be added from that copied datastore to the VM. The virtual disk will be given a new, unique UUID so it does not interfere with the original virtual disk . It will be added to the same virtual SCSI controller as the original disk.The virtual disk will then be Storage vMotioned to the original datastore. If the copied datastore is then clear of any registered VMs (it should be unless someone manually put on one it) it will be unmounted, detached from all hosts and then destroyed on the FlashArray. The VM will not be powered-on to prevent network collisions.
  • Both options are selected. This will bring up a copy of the datastore that the virtual disk sits on from the snapshot you choose. The source virtual disk will be removed and deleted from the datastore and the recovered virtual disk will be added to the VM in the same controller as the original. The recovered virtual disk will then be Storage vMotioned to the original datastore. If the copied datastore is then clear of any registered VMs (it should be unless someone manually put on one it) it will be unmounted, detached from all hosts and then destroyed on the FlashArray. The VM will not be powered-on to prevent network collisions.

This release only supports recovering the original VMDK to the VM or a point-in-time copy of the VMDK to the original VM. Adding it to a different VMDK will be a feature in the future.

Raw Device Mapping Recovery

Once, you have connected to vCenter and the FlashArray, choose “Raw Device Mapping” as the option. This will enable the “Get Virtual Machines” button. Depending on your filters, it will return all or a subset of the VMs in your vCenter. Choose the VM you want.

Once a virtual machine has been chosen, the RDMs will be listed. This will show the RDM NAA and the size. Choose the RDM you want to recover.

 

There is only one recovery option for RDMs.

The behavior will be as such depending upon your selections:

  • No option is checked: This will bring up a new volume from the chosen snapshot of the chosen RDM. It will be added to the same virtual SCSI controller as the original RDM of the same VM.
  • Only “Replace original VM/VMDK/RDM” is selected: In this case, the RDM will be temporarily removed from the VM and then the corresponding FlashArray volume will be refreshed from the chosen snapshot. The RDM will be added back to the identical SCSI slot and controller of the VM.

Choosing a Snapshot

The last step is choosing a snapshot, or creating a new one. If you want to create a new one, enter a new snapshot name and click the “Create Snapshot” button. If the name is valid, and the object is on the connected FlashArray the snapshot will be created and the name reported.

A new snapshot:

If you already have a snap, or want to use that one, go to the last box and click “Gather Snapshots”. This will list all of the available snapshots that host that VMFS, VM, VMDK, or RDM. It will list the snapshot name and time stamp.

Once you have chosen a snapshot, and are sure you are ready, click the “Execute” button. This operation can take some time, so be patient. The tool cannot be used during an operation and may go unresponsive during certain operations. That is normal–just let it finish.

Logging

The tool has a operation logging and error logging box at the bottom. Encountered errors or log messages will appear there.

Next Steps…

That’s it! Please let me know any feedback. Also, depending on how long your rescans are and if you choose storage vMotion, it can take some time to complete. So, be patient and let it run, it might be unresponsive during certain PowerCLI operations.

 

6 thoughts on “PowerShell GUI VMware and FlashArray Snapshot Management Tool”

  1. Hi Cody

    i am Bulent from Turkey.ASP partner TAra Sistem

    i get error message like this how can i fix that while runing scripts

    2/14/2017 2:34:47 PM Get-Datastore Could not establish trust relationship for the SSL/TLS secure channel with authority ‘xxx.xxx.xxx.xxx.

    1. I have seen this intermittently myself as well. I am not entirely sure why though. I have a suspicion that is might have to do with this:
      Set-PowerCLIConfiguration -invalidcertificateaction “ignore” -confirm:$false |out-null

      Could you remove that line from the script (it is line 47) and let me know if the problem persists?

      In the short term, just disconnect and re-connect to the vCenter with the buttons. Though let me know if the above suggestion helps.

  2. I’m sure it something simple but can you help?

    I’m running VMware vSphere PowerCLI 6.3.0 R1 Patch 1 & Release 1.7.4.0 PurePowerShellSDKInstaller.msi, but when I run the PureStorageVMwareRecoveryTool.ps1 (as admin) I get this:

    PS C:\PURE> C:\PURE\PureStorageVMwareRecoveryTool.ps1
    At C:\PURE\PureStorageVMwareRecoveryTool.ps1:115 char:13
    + <a href="/open-source" class="js-selected-navigation-item …
    + ~
    The '<' operator is reserved for future use.
    At C:\PURE\PureStorageVMwareRecoveryTool.ps1:117 char:13
    + <a href="/business" class="js-selected-navigation-item na …
    + ~
    The '<' operator is reserved for future use.
    At C:\PURE\PureStorageVMwareRecoveryTool.ps1:119 char:13
    + <a href="/explore" class="js-selected-navigation-item nav …
    + ~
    The '<' operator is reserved for future use.
    At C:\PURE\PureStorageVMwareRecoveryTool.ps1:121 char:13
    + <a href="/pricing" class="js-selected-navigation-item nav …
    + ~
    The '<' operator is reserved for future use.
    At C:\PURE\PureStorageVMwareRecoveryTool.ps1:123 char:11
    +
    + ~
    The ‘<input name="utf8" type="hidden" value="✓" …
    + ~
    The ampersand (&) character is not allowed. The & operator is reserved for future use; wrap an ampersand in double quotation marks ("&") to pass it as part of a string.
    At C:\PURE\PureStorageVMwareRecoveryTool.ps1:7353 char:11
    + © 2017 <span title="0.33992s from github-fe119-cp1-prd …
    + ~
    The ampersand (&) character is not allowed. The & operator is reserved for future use; wrap an ampersand in double quotation marks ("&") to pass it as part of a string.
    At C:\PURE\PureStorageVMwareRecoveryTool.ps1:7353 char:23
    + © 2017 <span title="0.33992s from github-fe119-cp1-prd …
    + ~
    The '<' operator is reserved for future use.
    At C:\PURE\PureStorageVMwareRecoveryTool.ps1:7353 char:29
    + … 2017 GitHub’ in expression or statement.
    At C:\PURE\PureStorageVMwareRecoveryTool.ps1:7353 char:100
    + … 992s from github-fe119-cp1-prd.iad.github.net”>GitHub, Inc.</l …
    + ~
    Missing argument in parameter list.
    Not all parse errors were reported. Correct the reported errors and try again.
    + CategoryInfo : ParserError: (:) [], ParentContainsErrorRecordException
    + FullyQualifiedErrorId : RedirectionNotSupported

  3. There almost seems like text has been copied from the entire web page and then saved as a ps1 file. Did you right click and save as from the source page (which is kind of what it looks like because the word “github” or “open source” is not in my code) or did you go to:

    https://github.com/codyhosterman/powercli/blob/master/PureStorageVMwareRecoveryTool.ps1

    And then copy from the text box? Or you can go directly here and just copy everything:

    https://raw.githubusercontent.com/codyhosterman/powercli/master/PureStorageVMwareRecoveryTool.ps1

    Let me know if that helps!

Leave a Reply

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