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.
Now the PowershellGet Module has been installed.
Before installing PowerCLI, please make sure to Uninstall any existing installations of PowerCLI.
- Right Click PowerShell, and Run as Administrator.
- Enter “Install-Module VMware.PowerCLi”
- You will be prompted to approve installation of NuGet. Enter “Y” for Yes
- You are prompted to confirm you are aware you are downloading the Module from a currently untrusted repository. Enter “Y” for Yes
- A progress window will appear at the top
- Enter “Install-Module “VMware.VIMAutomation.SRM”
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
- Go to this site
- Download the Zip file
- Extract the zip file on the same server you installed the earlier modules
- Enter the following command, adjusting your command for the location you extracted the files
- Now you will access to the SRM Cmdlets.
- 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
- 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.
- To start a Test Recovery of the plan
- If we check the web client we see this plan has was able to successfully complete the test recovery.
- Very similar process for Cleanup of a Test Recovery.
- And Recovery Plan goes back to a Ready state
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:
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