{"id":234,"date":"2014-12-02T08:56:32","date_gmt":"2014-12-02T15:56:32","guid":{"rendered":"http:\/\/blog.gptnet.net\/?p=234"},"modified":"2017-03-16T08:28:48","modified_gmt":"2017-03-16T15:28:48","slug":"vmware-site-recovery-manager-5-8-command-on-srm-with-powershell-bug","status":"publish","type":"post","link":"https:\/\/blog.gptnet.net\/?p=234","title":{"rendered":"VMware Site Recovery Manager 5.8 command on SRM with Powershell bug"},"content":{"rendered":"<p>Hello, we have another VMware Site Recovery Manager (SRM) bug. This time it&#8217;s with Command on SRM server and Powershell scripts.<\/p>\n<p>I am not SRM developer but it seems SRM itself parses commands before passing it to Windows OS for execution. Sometimes it causes issues.<br \/>\nLet&#8217;s take a look at this line:<br \/>\n<code>c:\\windows\\system32\\windowspowershell\\v1.0\\powershell.exe -Command \"(Invoke-Command -ComputerName REMOTEPC -FilePath \"C:\\SRM\\test1.ps1\")\"<\/code><\/p>\n<p>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.<\/p>\n<p>The same script (test1.ps1) will fail to execute when we call to execute via SRM. Let&#8217;s take a look at SRM&#8217;s vmware-dr log:<br \/>\n<code>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\")\"<br \/>\n2014-12-01T09:24:20.348-05:00 [00884 verbose 'Recovery' ctxID=39eff996 opID=3913b17c] COMMAND LINE ENVIRONMENT SETTINGS::<br \/>\n<----cut----><br \/>\n2014-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\\\")\"<\/code><\/p>\n<p>As you can see SRM messes up double quotes <code>C:\\SRM\\test1.ps1\\\"<\/code>, thus making command invalid.<\/p>\n<p>If we format this command sightly different (removed wrapping double quotes for C:\\SRM\\test1.ps1)<br \/>\n<code>c:\\windows\\system32\\windowspowershell\\v1.0\\powershell.exe -Command \"(Invoke-Command -ComputerName REMOTEPC -FilePath C:\\SRM\\test1.ps1)\"<\/code><br \/>\nscript executes flawlessly from both SRM and natively Windows OS.<\/p>\n<p><strong>Workaround<\/strong><br \/>\nReplace space in file path&#8217;s name (think about DOS days haha) and remove double quotes wrapping.<\/p>\n<p><strong>Conclusion<\/strong><br \/>\nMy ticket is still open with VMware and engineering team is currently investigating. You will be affected by this bug if your script&#8217;s file path name contains spaces. You need to wrap it with quotes.<\/p>\n<p><strong>Update: 14\/05\/2015<\/strong><br \/>\nVMware published internal KB 2116057<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Hello, we have another VMware Site Recovery Manager (SRM) bug. This time it&#8217;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 &hellip; <a href=\"https:\/\/blog.gptnet.net\/?p=234\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[84],"tags":[68,45,62,70,65,69],"class_list":["post-234","post","type-post","status-publish","format-standard","hentry","category-vmware","tag-bug","tag-powershell-2","tag-recovery-manager","tag-site","tag-srm","tag-vmware"],"_links":{"self":[{"href":"https:\/\/blog.gptnet.net\/index.php?rest_route=\/wp\/v2\/posts\/234","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.gptnet.net\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.gptnet.net\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.gptnet.net\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.gptnet.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=234"}],"version-history":[{"count":8,"href":"https:\/\/blog.gptnet.net\/index.php?rest_route=\/wp\/v2\/posts\/234\/revisions"}],"predecessor-version":[{"id":282,"href":"https:\/\/blog.gptnet.net\/index.php?rest_route=\/wp\/v2\/posts\/234\/revisions\/282"}],"wp:attachment":[{"href":"https:\/\/blog.gptnet.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=234"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.gptnet.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=234"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.gptnet.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=234"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}