title: Using output from a PowerShell command in a windows batch file
body: <p>I have a path in variable (script parameter) <code>%2</code>.
  I need to do  the following:</p>
  
  <ol>
  <li>Extract the leaf (last folder from the path) to a variable. </li>
  <li>Run the following command: <code>robocopy %2 \\somepath\%leaf</code></li>
  </ol>
  
  <p>I was told this could be done in PowerShell (cause I've tried going with batch file alone and failed miserably) Here's a pseudocode representation of what I'd like to achieve:</p>
  
  <pre><code>set leaf = powershell -command (split-path %2 -leaf)
  robocopy %2 \\somepath\%leaf
  </code></pre>
  
  <p>Any idea how to write this correctly?
  Thank you.</p>