title: Alternatives to invoke-expression
body: <p>I have this function:</p>
  
  <pre><code>function traced()
  {
      write-host "$args"
      invoke-expression -Command "$args"
  }
  </code></pre>
  
  <p>and I use it in several places like <code>traced cp "$($_.FullName)" (join-path $directory $newfile)</code> so that I have a log of all of the places that get copied (or removed, or whatever)</p>
  
  <p>But when the directory contains spaces and dashes, it results in invoke-expression throwing.</p>
  
  <p>I guess I could just define <code>traced-cp</code> and <code>traced-rm</code>, but if I have a lot of functions I want to trace, what's the generic answer? I just want a function that prints, then evaluates, the exact command its given. From what I understand, the <code>&amp;</code> operator isn't what I want here-- It won't work for shell builtins.</p>