This is the first post in a series about using PowerShell to automate steps in a VMware Site Recovery Manager (SRM) workflow. I will be posting bits and pieces as I learn more and if everything works the way I would like I will post an overview of my testing and recovery procedure.
To use PowerShell in a Command Step of a recovery plan you will need to do the following:
- Install PowerShell and related components on your SRM server as that is where the command steps are run.
- Create a recovery plan. I would recommend creating one without any protection groups that way you can iteratively test the setup without involving any VMs. Once the basics are working you can add some protection groups and VMs.
- Create a simple PowerShell script that outputs some data so you can tell if it is running correctly. A simple example is below.
- Add a command step to run your PowerShell script. Something like this “C:\WINDOWS\system32\WindowsPowerShell\v1.0\powershell.exe c:\srm_plan.ps1”
- Initiate a test of your recovery plan.
- Click the history tab and view the most recent test. You should see the last 4k of output for your PowerShell script.
Be aware that SRM executes command steps as LocalSystem so pass through authentication will not work and some environment variables may not be set as they are with your account.
My next post will show you how to access the environment variables VMware provides to help you do something useful in the script.
A simple one line script for testing purposes. Make sure to output a value instead of doing a Write-Host.