Summary: How to work and setup powershell and powercli for VMware Site Recovery Manager 5.1.
Date: Around 2012
Refactor: 29 April 2025: Checked links and formatting.
PowerShell can be a great way to help you create the site recovery you really want. This article talks about installing PowerCLI on a SRM server installed as described here. Also, running the script automatically and adding them into your recovery plan will be discussed.
We have a Site Recovery Server 5.1 server which is installed as described here. To install PowerCLI we first have to install PowerShell, which, on Windows Server 2008 R2 is a feature and can be installed as such:
Now we can install PowerCLI. We'll use PowerCLI 5.1 R2, which was released on 2013-02-11 and is released as this executable:
Run the executable as an administrator and keep all the defaults during installation.
Also, to speed up PowerCLI go to the control panel → Internet Options → Advanced tab → Security Section → Uncheck the “Check for publisher's certificate revocation” checkbox.
Now, start PowerCLI as an administrator using the shortcuts on the desktop and issue:
Set-ExecutionPolicy RemoteSigned -force Set-PowerCLIConfiguration -InvalidCertificateAction ignore -ProxyPolicy NoProxy -Confirm:$False
Note: For more information regarding installing, configuring and getting started with PowerShell and PowerCLI see Getting Started with PowerShell and vSphere PowerCLI.
Note: In case you also use 32 bits commands you should also do this in the PowerCLI for 32 bits.
Create a AD service account and grant the account the following permissions:
Note that the vCenter permissions might be a bit too much. You could just grant permissions at the correct cluster, or use specific roles.
Then configure the SRM service to run under this account:
Restart the service to make sure the created account works and test your Site Recovery Manager setup.
Because adding scripts to recovery plans will be a common tasks we put some extra effort in making this look nice. Because adding a powershell script to a recovery plans uses a lot of text in the commands this means it gets quite confusing and unreadable. To prevent this we'll use a redirect command. Create a redirect.cmd in the same location where your scripts will be stored and put the following lines in it:
redirect.cmd:
@echo off C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -psc "C:\Program Files (x86)\VMware\Infrastructure\vSphere PowerCLI\vim.psc1" "& '%1'"
Now you can add a powershell script to a recovery plan like this:
For reference, the command in the Command Step is this:
c:\windows\system32\cmd.exe /C g:\scripts\redirect.cmd g:\scripts\srmrdms.ps1
Note that without the redirect script you should use this command, and would have to load the VMware snap-ins inside the script:
C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -File g:\scripts\srmrdms.ps1
You have now added an extra step to the recovery plan to run a script, which in this case sets the RDM settings correctly.