Requirements:

  • PowerShellGet Module
  • PowerCLI
  • PowerCLI SRM
  • MeadowCroft Module/Cmdlets

 

The latest PowerCLI and PowerCLI SRM are generally not available for conventional download, and the PowerShellGet Module is needed to download and install them.

 

PowershellGet is inherently included in:

  • Windows 10+
  • Server 2016+
  • Windows Management Framework (WMF) 5+
  • Powershell 6

 

For Powershell versions 3.0 and 4.0, the module can be installed through this MSI:

http://go.microsoft.com/fwlink/?LinkID=746217&clcid=0x409

 

For more information on PowerShellGet:

https://docs.microsoft.com/en-us/powershell/gallery/psget/get_psget_module

To install PowerShellGet, simply download the MSI(from link above) and launch the installer.

clip_image001

clip_image002

clip_image003

clip_image004

Now the PowershellGet Module has been installed.

Before installing PowerCLI, please make sure to Uninstall any existing installations of PowerCLI.

  1. Right Click PowerShell, and Run as Administrator.
    1. clip_image005
  2. Enter “Install-Module VMware.PowerCLi”
  3. You will be prompted to approve installation of NuGet. Enter “Y” for Yes
    1. clip_image006
  4. You are prompted to confirm you are aware you are downloading the Module from a currently untrusted repository. Enter “Y” for Yes
    1. clip_image007
  5. A progress window will appear at the top
    1. . clip_image008
  6. Enter “Install-Module “VMware.VIMAutomation.SRM”
    1. clip_image009

 

For more information on the PowerCLI and PowerCLI SRM Modules

https://www.powershellgallery.com/packages/VMware.PowerCLI/6.5.4.7155375

https://www.powershellgallery.com/packages/VMware.VimAutomation.Srm/6.5.1.5374694

Next, we need to download and install the Meadowcroft SRM Module

  1. Go to this site
    1. https://code.vmware.com/samples/2512/SRM-PowerCLI-Cmdlets
  2. Download the Zip file
    1. clip_image010
  3. Extract the zip file on the same server you installed the earlier modules
  4. Enter the following command, adjusting your command for the location you extracted the files
    1. clip_image011
  5. Now you will access to the SRM Cmdlets.
    1. Note: Each time you start powershell you will need to run the final Import-Module command from the previous step

For Running SRM command we must now connect to the vCenter Server and the SRM Server at the Recovery Site

  1. clip_image012
  2. clip_image013
  3. It will automatically connect to the vCenter server you are connected to, however, if vCenter server has multiple SRM servers, you will need to specify.
  4. clip_image015
  5. To start a Test Recovery of the plan
  6. clip_image016
  7. If we check the web client we see this plan has was able to successfully complete the test recovery.
    1. clip_image018
  8. Very similar process for Cleanup of a Test Recovery.
  9. clip_image019
  10.  And Recovery Plan goes back to a Ready state
  11. clip_image020

 

A sample Script might look like:


param(

[switch]$testrecovery,

[switch]$cleanup

)

Import-Module "C:\........\SRM-Cmdlets-master\Meadowcroft.Srm.psd1"

$creds = Get-VICredentialStoreItem -file C:\......\creds.xml

Connect-VIServer vcenterserver -User $creds.User -Password $creds.Password

Connect-SrmServer

IF ($testrecovery)

{Get-SRMRecoveryPlan TestPlan | Start-SRMRecoveryPlan -RecoveryMode Test -Confirm:$false}

IF ($cleanup)

{Get-SRMRecoveryPlan TestPlan | Start-SRMRecoveryPlan -RecoveryMode CleanupTest -Confirm:$false}

This would require first creating stored credentials using New-VICredentialStoreItem.

The scheduled task would look something like this:

clip_image021

Where the Programs/Script section is:
C:\WINDOWS\system32\windowspowershell\v1.0\powershell.exe
And the “Add Arguments” section is:
-executionpolicy bypass c:\ pathtofile \srmrecovery.ps1 -testrecovery

Which would perform a test recovery.
A different argument would do a cleanup of the test recovery plan :
-executionpolicy bypass c:\pathtofile\srmrecovery.ps1 -cleanup


0 Comments

Leave a Reply