VMware Cloud Community
Guv
Enthusiast
Enthusiast
Jump to solution

SRM Environment variables in scripts

I am having issues running the SRM environment variables such as :

VMware_RecoveryMode and VMware_VC_Host.

I want to know how to apply these to scripts like in a if and else statements.

So if i pass the variable via echo and run it in a step in a recovery plan it works so the script is called testrun :

echo %VMware_RecoveryMode% >> D:\scripts\MES\logs\logfile.log

and so when i add a step in the recovery step to the location of this script like :

C:\Windows\System32\cmd.exe /c d:\scripts\MES\Testrun.bat

It runs fine when i run a test as it outputs test in the log fils.

But now when i run this variable in a script with the if and else statements when doing a test recovery it does not work.  So an example of the script is :

If "%VMware_RecoveryMode%==test"

echo %VMware_RecoveryMode% >> D:\scripts\MES\logs\logfile.log

This fails in a recovery plan.   I have tried various combinations of if syntax with quotation marks, brackets, and then commands, but it keeps failing.

Has anyone used these variables in scripts and made it to work, can anyone send a sample of a working script.

Thanks

Reply
0 Kudos
1 Solution

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

Very limited BAT/CMD knowledge here, but shouldn't that be

If "%VMware_RecoveryMode%" == "test"


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

View solution in original post

Reply
0 Kudos
2 Replies
LucD
Leadership
Leadership
Jump to solution

Very limited BAT/CMD knowledge here, but shouldn't that be

If "%VMware_RecoveryMode%" == "test"


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

Reply
0 Kudos
Guv
Enthusiast
Enthusiast
Jump to solution

thanks a lot that worked.

Reply
0 Kudos