posted

4 Comments

Hello all,

I did say some time ago that I would help get you started with PowerCLI in the SRM world.  I have taken a lot of time to get here but I will help today.  I had a lot of issues making it work – my own issues that were tough but the wonderful Alan Renouf of this blog and this one was a big help!

I suggest you review the SRM and Scripting blog I did previously for background info.

We have a number of things to do before you can execute a PowerCLI script during a failover.

PowerShell / PowerCLI

You need to have PowerCLI running on the SRM server.  Use the instructions here to do that and make sure it all works!  Make sure you test and confirm it works.

Since the PowerCLI scripts will need to execute in a security context that works for them, I suggest that you consider starting the SRM service as the user who you want to execute the scripts.  This is how I do it.  If you do, make the change and confirm that SRM is running afterwards.  You may need to do this on both SRM services if you do protection in both directions.  An alternative may be to store the necessary credentials in the PS script.

Script Repository

You need a place to keep your scripts.  I use G:Scripts on my SRM server.  I found it to be best if they were local.

Testing

You should log onto the SRM console as the user who the service is running in and make sure your scripts work as you expect them too at the command line!

Command line for SRM

The command line you will add to the Command step is simple :

c:windowssystem32windowspowershellv1.0powershell.exe -file g:scriptslistofvms.ps1

If you need help with setting up or testing the execution of scripts you can check out this blog I wrote about it called SRM and Scripting which is here.

Remember to put the script in the right place.  Often that is in the Post Actions for the VM it may impact.  You can learn more about script placement here.

Testing your Script as part of SRM failover

Once your script is done, and stored in the right place, and you have the right command line in a call out, you are ready to do your test failover.  Once it is done make sure there is no errors in the History Report, and see if your script has done what it was supposed to.

Summary

You have just installed PowerCLI, configured SRM to execute a PowerCLI script and tested it.  This is just the start.  You now have the ability to have very powerful scripts executed when you need them executed in the failover workflows of SRM.  There are great examples of scripts that you can execute now in the VMware vSphere PowerCLI Reference book.

If you have questions or comments let me know in the comments section.  I appreciate all comments.  Below are some links that may be useful for you.

PS: I apologize for no screenshots.  My labs have all been upgraded to a new version of SRM (wait to you see my blog postings on July 12th!).  I will add in pictures in the future.  In the meantime if you have problems please leave me a comment.

Michael

PowerCLI help – http://www.simple-talk.com/sysadmin/virtualization/10-steps-to-kick-start-your-vmware-automation-with-powercli/

Can a script stop a recovery plan – /uptime/2010/08/can-a-script-or-message-call-out-stop-a-recovery-plan-and-a-little-bit-more.html

Getting Started with scripting and SRM – /uptime/2010/09/vmware-vcenter-site-recovery-manager-and-scripting-.html

PowerCLI community (samples and help) – http://communities.vmware.com/community/vmtn/developer

Failover of persistent desktops using SRM and View 4.6 – http://www.virtu-al.net/2011/06/07/failover-of-persistent-desktops-using-srm-and-view-4-6/

=== END ===