VMware Cloud Community
malarshyam
Contributor
Contributor
Jump to solution

Scriptsin Recovery Plan

Hi,

In a recovery plan, I need to execute a script in the SRM server in the recovery site in a Recovery plan to execute a set of powershell scripts in the vcentre server in the recovery site.

I have decided to run a batch file in the SRM server to execute the set of scipts in the vcentre server.

I am not sure about the commands to be used in this batch file to run the scripts in the vcentre server, can someone help me in this.

0 Kudos
1 Solution

Accepted Solutions
mal_michael
Commander
Commander
Jump to solution

No problem.

The command will run whatever script you want:

psexec \\vcenter_name_or_ip -u user_account -p password powershell.exe &'c:\my scripts\test.ps1'

What appears in bold is a path to script on vCenter server.

Michael.

View solution in original post

0 Kudos
13 Replies
msatya
Enthusiast
Enthusiast
Jump to solution

Hi if got the script can you please share with me

-------------------------
please award points if you see fit.Thankshttp://imagicon.info/cat/5-59/vbsmile.png

0 Kudos
malarshyam
Contributor
Contributor
Jump to solution

Hi Michael,

The article given by you talks about opening the console in SRM server and running a powershell script.

I am asking for a command which redirects the above powershell script to trigger another powershell script in vcenter server.

Thanks

Malar

0 Kudos
malarshyam
Contributor
Contributor
Jump to solution

Sure Satya, If I get the command for thsi I will let you know

Thanks

Malar

0 Kudos
mal_michael
Commander
Commander
Jump to solution

The article explains how to run powershell script as part of recovery plan.

As an example, in the article that powershell script edits VMs. In your case powershell script will run psexec to run script on remote server, something like:

psexec \\vcenter_name_or_ip -u user_account -p password powershell.exe ....

Michael.

malarshyam
Contributor
Contributor
Jump to solution

Hi MIchael,


Thanks for the reply.

I just have one doubt it might look silly though,  the command which you have given last will it run another powershell script or edit the virtual machine in vcenter.

Thanks

Malar

0 Kudos
mal_michael
Commander
Commander
Jump to solution

No problem.

The command will run whatever script you want:

psexec \\vcenter_name_or_ip -u user_account -p password powershell.exe &'c:\my scripts\test.ps1'

What appears in bold is a path to script on vCenter server.

Michael.

0 Kudos
malarshyam
Contributor
Contributor
Jump to solution

Thanks a lot for your help.

I tried dpoing the way you mentioned but the recovery plan returns an error message "Warning - The command 'c:\windows\system32\cmd.exe' returned a non-zero value: 1." When I saw the log in SRM it states it is not able to psexec' is not recognized as an internal or external command, operable program or batch file."

Any help in this regard please.

Thanks

Malar

0 Kudos
mal_michael
Commander
Commander
Jump to solution

psexec is not a Windows command. It is a utility you need to download and put on SRM server.

http://technet.microsoft.com/en-us/sysinternals/bb897553

0 Kudos
malarshyam
Contributor
Contributor
Jump to solution

Yes Michael, I downloaded it and placed it in c:\ of the SRM Server. The error which I mentioned above is after I did this.

Thanks

Malar

0 Kudos
mal_michael
Commander
Commander
Jump to solution

You need to provide a full path to exe file in SRM command.

0 Kudos
malarshyam
Contributor
Contributor
Jump to solution

When I try running the same command in SRM it runs properly but then when I run it in SRM recovery plan it keeps giving this error message.

0 Kudos
malarshyam
Contributor
Contributor
Jump to solution

Hi Michael,

Thanks lot for your help.

I figured where I went wrong, I went wrong in teh authentication part and the SRM service awas set in delayed start.

After I rectified all these the issue got resolved.

Thanks

Malar

0 Kudos