VMware Site Recovery Manager 5.8 command on SRM with Powershell bug

Hello, we have another VMware Site Recovery Manager (SRM) bug. This time it’s with Command on SRM server and Powershell scripts.

I am not SRM developer but it seems SRM itself parses commands before passing it to Windows OS for execution. Sometimes it causes issues.
Let’s take a look at this line:
c:\windows\system32\windowspowershell\v1.0\powershell.exe -Command "(Invoke-Command -ComputerName REMOTEPC -FilePath "C:\SRM\test1.ps1")"

In the example above we are executing Powershell script on remote host (REMOTEPC). Everything looks standard and it works if you run it directly in the Windows Operating System.

The same script (test1.ps1) will fail to execute when we call to execute via SRM. Let’s take a look at SRM’s vmware-dr log:
2014-12-01T09:24:20.348-05:00 [00884 info 'Recovery' ctxID=39eff996 opID=3913b17c] [recovery-plan-1036482.beforePrepareStorage-0] Executing command c:\windows\system32\windowspowershell\v1.0\powershell.exe -Command "(Invoke-Command -ComputerName REMOTEPC -FilePath "C:\SRM\test1.ps1")"
2014-12-01T09:24:20.348-05:00 [00884 verbose 'Recovery' ctxID=39eff996 opID=3913b17c] COMMAND LINE ENVIRONMENT SETTINGS::
<----cut---->
2014-12-01T09:24:20.348-05:00 [00884 verbose 'SysCommandWin32' ctxID=39eff996 opID=3913b17c] Starting process: "c:\windows\system32\windowspowershell\v1.0\powershell.exe" -Command "(Invoke-Command -ComputerName REMOTEPC -FilePath C:\SRM\test1.ps1\")"

As you can see SRM messes up double quotes C:\SRM\test1.ps1\", thus making command invalid.

If we format this command sightly different (removed wrapping double quotes for C:\SRM\test1.ps1)
c:\windows\system32\windowspowershell\v1.0\powershell.exe -Command "(Invoke-Command -ComputerName REMOTEPC -FilePath C:\SRM\test1.ps1)"
script executes flawlessly from both SRM and natively Windows OS.

Workaround
Replace space in file path’s name (think about DOS days haha) and remove double quotes wrapping.

Conclusion
My ticket is still open with VMware and engineering team is currently investigating. You will be affected by this bug if your script’s file path name contains spaces. You need to wrap it with quotes.

Update: 14/05/2015
VMware published internal KB 2116057

This entry was posted in VMware and tagged , , , , , . Bookmark the permalink.

Leave a Reply

Your email address will not be published.