title: Powershell - Run SCP command using CYGWIN but also expand variables
body: <p>I need to expand variables before running the <code>SCP</code> command as a result I can't use single quote. If I run the script using double quotes in  <code>Powershell ISE</code> it works fine. </p>
  
  <p>But doesn't work if I run the script through command prompt.</p>
  
  <p>I'm using zabbix to run the script which calls the script as <code>[cmd /C "powershell -NoProfile -ExecutionPolicy Bypass -File .\myscript.ps1"]</code></p>
  
  <p>Here is the code that needs to run SCP using Cygwin bash.</p>
  
  <pre><code>if ((test-path  "$zipFile"))
  
  { 
  
  C:\cygwin\bin\bash.exe -l "set -x; scp /cygdrive/e/logs/$foldername/dir1/$foldername.zip root@10.10.10.10:~/"
  
  }
  </code></pre>
  
  <p>Output: </p>
  
  <pre><code>/usr/bin/bash: set -x;  /cygdrive/e/logs/myfolder/dir1/server.zip root@10.10.10.10:~/: No such file or directory
  </code></pre>
  
  <p>If I run the same command above in Cygwin manually it works.</p>
  
  <p>I even tried to use <code>bash -l -c</code> but then the SSH session is stuck maybe because the <code>root@10.10.10.10</code> becomes $1 according to the documentation.</p>
  
  <p><a href="http://man7.org/linux/man-pages/man1/bash.1.html" rel="nofollow noreferrer">Documentation link</a></p>
  
  <pre><code>   -c        If the -c option is present, then commands are read from
  
               the first non-option argument command_string.  If there are
  
               arguments after the command_string, the first argument is
  
               assigned to $0 and any remaining arguments are assigned to
  
               the positional parameters.  The assignment to $0 sets the
  
               name of the shell, which is used in warning and error
  
               messages.
  </code></pre>